problem in gridview control of user control
My problem is I am setting the datasource from parent page.But if I set disable to certain columns of gridview the event of the controls inside those disabled column template gets fired. Like I have a checkbox in one column, if disable that column from parent page while data binding the check_checked event is being fired. here my code- user control aspx
<asp:TemplateField HeaderText="Exclude Null" ItemStyle-Width="50px">
<HeaderTemplate>
Exclude Null
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkExNull" OnCheckedChanged="chkExNull_OnCheckedChanged"
AutoPostBack="true" />
</ItemTemplate>
<ItemStyle HorizontalAlign="left" VerticalAlign="Top" />
<HeaderStyle HorizontalAlign="left" VerticalAlign="Top" />
</asp:TemplateField>
.cs file of parent
GridView gvCondition = (GridView)ucCondition.FindControl("gvCondition");
gvCondition.DataSource = ConditionFieldCollection;
gvCondition.Columns[5].Visible = false;
gvCondition.Columns[6].Visible = false;
gvCondition.Columns[7].Visible = false;
gv开发者_如何学CCondition.Columns[8].Visible = false;
gvCondition.DataBind();
What should I do, and is there any other way through which I can hide some of the columns of grid view control of user control??
Before your DataBind()
. write this:
gvCondition.DataBound += new EventHandler(gvwCondition_DataBound);
and write in that method, the code to hide the columns.
Hope that helps.
精彩评论