Hi,
I am using radiobuttonlist and textbox in the gridview. I
need to do operations on radiobuttonlist so that it should reflect on
textbox . this is to be done after gridview_rowediting event fires i.e
when we can see "update" and "cancel" buttons. I tried like this,
protected void GridView1_RowEditing(object sender,
GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
GridViewRow editingRow = GridView1.Rows[e.NewEditIndex];
RadioButtonList rbl = RadioButtonList)editingRow.Cells[17].FindControl("rblist11");
rbl.Visible = true;
TextBox txtamt =
(TextBox)editingRow.Cells[18].FindControl("TextBox3");
txtamt.Enabled = true;
if (rbl.SelectedItem.Value.Contains("1"))
{
txtamt.Enabled = true;
}
else if (rbl.SelectedItem.Value == "2")
{
txtamt.Enabled = true;
}
else if (rbl.SelectedItem.Value == "0")
{
txtamt.Enabled = false;
}
}
here default selected value is "0" given in source.
My problem here is when I am changing the selecteditem, the corresponding action is not done.
if this action is not done in rowediting event, Please give me the appropriate solution.
Marimuthu ArigovindasamyPosted Jun 28, 2010, 3:32 AM
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
BindGrid();
}
private void BindGrid()
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\Muthu\\Tech\\Sample.xls" + ";" +
"Extended Properties=Excel 8.0;";
OleDbConnection oledbConn = new OleDbConnection(strConn);
oledbConn.Open();
OleDbCommand oledbCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
OleDbDataAdapter oledbDataAdapter = new OleDbDataAdapter();
oledbDataAdapter.SelectCommand = oledbCommand;
DataSet ds = new DataSet();
oledbDataAdapter.Fill(ds);
grd1.DataSource = ds.Tables[0].DefaultView;
grd1.DataBind();
}
protected void grd1_RowEditing(object sender, GridViewEditEventArgs e)
{
grd1.EditIndex = e.NewEditIndex;
BindGrid();
}
protected void grd1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = grd1.Rows[e.RowIndex];
string aa = ((TextBox)(row.Cells[1].Controls[0])).Text;
}
protected void grd1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
}
aspx code:
<asp:GridView ID="grd1" runat="server" AutoGenerateColumns="False" PageSize="1"
onrowdatabound="grd1_RowDataBound"
onrowcancelingedit="grd1_RowCancelingEdit" onrowediting="grd1_RowEditing"
onrowupdating="grd1_RowUpdating">
<Columns>
<asp:CommandField ShowEditButton="True" />
Columns>
asp:GridView>