asp.net - Single gridview on multiple tabs -
is possible use single gridview , display on multiple tabs (ajax tabcontainer)? want bind different datasources grid on different tabs. using 3 gridviews (for 3 tabs) purpose.
<asp:tabcontainer id="tabcontainer1" runat="server" useverticalstripplacement="true" autopostback="true" onactivetabchanged="tabcontainer1_activetabchanged"> <asp:tabpanel id="tp1" runat="server"> <headertemplate> tab 1 </headertemplate> <contenttemplate> <p>test tab 1</p> <asp:gridview id="gridview1" runat="server" width="100%" viewstatemode="enabled" onrowediting="gridview1_rowediting"> <columns> <asp:commandfield showdeletebutton="true" showeditbutton="true" /> </columns> </asp:gridview> </contenttemplate> </asp:tabpanel> <asp:tabpanel id="tp2" runat="server"> <headertemplate> tab 2 </headertemplate> <contenttemplate> <p>test tab 2</p> <asp:gridview id="gridview2" runat="server" autogeneratecolumns="true" width="100%" viewstatemode="enabled"> </asp:gridview> </contenttemplate> </asp:tabpanel> <asp:tabpanel id="tp3" runat="server"> <headertemplate> tab 3 </headertemplate> <contenttemplate> <p>test tab 3</p> <asp:gridview id="gridview3" runat="server" autogeneratecolumns="true" width="100%" viewstatemode="enabled"> </asp:gridview> </contenttemplate> </asp:tabpanel> </asp:tabcontainer>
code behind:
protected void tabcontainer1_activetabchanged(object sender, eventargs e) { try { if (tabcontainer1.activetabindex == 0) { //bind datasource 1; } if (tabcontainer1.activetabindex == 0) { //bind datasource 2; } }etc.
for showing gridview1 in tabpanel 2
tp2.controls.add(gridview1);
general form
<tabpanelid>.controls.add(<gridviewid>);
Comments
Post a Comment