Hi,
I am new to C# and seeking for the assistance.
Problem is,
I have an Add, Edit, Delete button and a gridview. What i want is when I
click the Add button I should not able to select row in gridview.
Gridview should look like disabled.
Here is my codes in gridview row created event.
if (e.Row.RowType == DataControlRowType.DataRow)
{
//e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
//e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.Attributes.Add("onclick",
Page.ClientScript.GetPostBackEventReference((Control)sender, "Select$" +
e.Row.RowIndex.ToString()));
}
thanks,
Loading
happy happyPosted Nov 29, 2010, 11:40 PM
Actuallly I dint understand your problem. But anyhow if you want to disable a row in grid dynamically, then you can easily apply styles for those particular rows dynamically in row databound. For this see below example. here i have disbled the first 3 rows. so in the head tag you can write the required styles for 'disabled' css class. if its help you,then ok. otherwise please explain your problem clearly, then it may help you to get exact reply.
protected void detailGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].CssClass = "diabled";
e.Row.Cells[1].CssClass = "diabled";
e.Row.Cells[2].CssClass = "diabled";
}
}