lapucca
asked on
How can I make certain columns of certain gridview rows be read only when data is bind and before Update?
Hi, I'm using vs2012.
Depending on if certain column not null and no blank then I would like to make that row's 3 columns to be read only while leaving other column still editable when in Edit mode. Same thing I would like to do when user in Edit mode change certain column's value then I would like to do the same. How can I do that in Grivdview control's when it's binding to datasource and when user submits Update?
Thank you.
Depending on if certain column not null and no blank then I would like to make that row's 3 columns to be read only while leaving other column still editable when in Edit mode. Same thing I would like to do when user in Edit mode change certain column's value then I would like to do the same. How can I do that in Grivdview control's when it's binding to datasource and when user submits Update?
Thank you.
ASKER
Is it in event RowDataBound that I do this?
If a checkbox comlumn is checked then I would like to make 3 of the columns of this row to be read only. I'm not sure how your example code will do that. Please elaborate. Thank you.
If a checkbox comlumn is checked then I would like to make 3 of the columns of this row to be read only. I'm not sure how your example code will do that. Please elaborate. Thank you.
in loading row event of gridview Try Like:
private void Mygridview _LoadingRow(object sender, DataGridRowEventArgs e)
{
var ObjRowdata = e.Row.DataContext as Sp_CustomerDetail;
if (ObjRowdata.Customer== Customer_Care)
e.Row.IsEnabled = false;
else
e.Row.IsEnabled = true;
}
private void Mygridview _LoadingRow(object sender, DataGridRowEventArgs e)
{
var ObjRowdata = e.Row.DataContext as Sp_CustomerDetail;
if (ObjRowdata.Customer== Customer_Care)
e.Row.IsEnabled = false;
else
e.Row.IsEnabled = true;
}
Hi
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim x As DataRowView = e.Row.DataItem
Dim dt As DataTable = x.DataView.ToTable
If dt.Rows(e.Row.DataItemIndex)("Your_Coloum_Name") Then
e.Row.Enabled=false
end if
End If
End Sub
ASKER
King,
e.Row.Enabled=false
That would disable the entire row. I only want certain cells during Edit to be not editable if a checkbox cell was checked. prior. I'm able to do this in Row_editing event but it doesn't look nice because the textbox still shows up for these cells but users just can't type in it.
Thank you.
e.Row.Enabled=false
That would disable the entire row. I only want certain cells during Edit to be not editable if a checkbox cell was checked. prior. I'm able to do this in Row_editing event but it doesn't look nice because the textbox still shows up for these cells but users just can't type in it.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
If e.Row.RowType = DataControlRowType.DataRow
Dim mycontrolID As Button or Linkbutton or ..etc = e.Row.findControl("yourcon
mycontrolID .Enabled=false
end if