how can i adjust gridview header ? asp.net c# -
i have gridview contains edititemtemplate
, itemtemplate
gridview
header not adjusting.how can adjust gridview
header . here gridview
here aspx.cs code :
<asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" enableviewstate="false" width="1000px" cellpadding="2" forecolor="#333333" allowpaging="true" height="400px" datakeynames="user_id" onrowcancelingedit="gridview1_rowcancelingedit" onrowdeleting="gridview1_rowdeleting" onrowediting="gridview1_rowediting" onrowupdated="gridview1_rowupdated" onrowupdating="gridview1_rowupdating" > <columns> <asp:templatefield accessibleheadertext="user_id" headertext="user_id"> <edititemtemplate> <asp:textbox id="txt_id" runat="server" text='<%# eval("user_id") %>'></asp:textbox> </edititemtemplate> <itemtemplate> <asp:label id="txt_id" runat="server" text='<%# eval("user_id") %>'></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield accessibleheadertext="name " headertext="name"> <edititemtemplate> <asp:textbox id="txt_name" runat="server" text='<%# eval("name") %>'></asp:textbox> </edititemtemplate> <itemtemplate> <asp:label id="txtname" runat="server" text='<%# eval("name") %>'></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield accessibleheadertext="user_name" headertext="user_name"> <edititemtemplate> <asp:textbox id="txt_username" runat="server" text='<%# eval("user_name") %>'></asp:textbox> </edititemtemplate> <itemtemplate> <asp:label id="txt_username" runat="server" text='<%# eval("user_name") %>'></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield accessibleheadertext="email" headertext="email"> <edititemtemplate> <asp:textbox id="txt_email" runat="server" text='<%# eval("email") %>'></asp:textbox> </edititemtemplate> <itemtemplate> <asp:label id="txt_email" runat="server" text='<%# eval("email") %>'></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield accessibleheadertext="password" headertext="password"> <edititemtemplate> <asp:textbox id="txt_password" runat="server" text='<%# eval("password") %>'></asp:textbox> </edititemtemplate> <itemtemplate> <asp:label id="txt_password" runat="server" text='<%# eval("password") %>'></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield accessibleheadertext="date" headertext="date"> <edititemtemplate> <asp:textbox id="txt_date" runat="server" text='<%# eval("date") %>'></asp:textbox> </edititemtemplate> <itemtemplate> <asp:label id="txt_date" runat="server" text='<%# eval("date") %>'></asp:label> </itemtemplate> </asp:templatefield> <asp:commandfield showeditbutton="true" /> <asp:commandfield showdeletebutton="true" /> </columns> <headerstyle horizontalalign="left" cssclass="header" backcolor="#7961da" font-bold="true" forecolor="white" /> <rowstyle backcolor="#f7f6f3" forecolor="#333333" /> </asp:gridview> </div> </form>
you can use alignment properties of header each field:
<asp:templatefield headerstyle-horizontalalign="left" headerstyle-verticalalign="middle"> ... </asp:templatefield>
if need more control on output, can create headertemplate:
<asp:templatefield> <headertemplate> <asp:label runat="server" text="..." /> ... </headertemplate> ... </asp:templatefield>
Comments
Post a Comment