hi to all
I am using a datagrid with template column(with a textbox). i do some changed in textbox(WITH IN DATAGRID) then i switch over to next paging
When i return back to my first page, i cant see what i change.(i.e) template column once again bind to old values. how can prevent state of template column controls on postback.
This is my coding
aspx page --------- <asp:datagrid id="DataGrid1" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="10pt" Width="248px" AllowPaging="True" BorderColor="#CCCCCC" BackColor="White" BorderStyle="None" BorderWidth="1px" CellPadding="3" EnableViewState="true" AutoGenerateColumns="False"> <FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle> <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle> <ItemStyle HorizontalAlign="Center" ForeColor="#000066"></ItemStyle> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" BorderWidth="2px" ForeColor="White" BorderStyle="Solid" BorderColor="Black" BackColor="#006699"></HeaderStyle> <Columns> <asp:BoundColumn DataField="subject_cd"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Subject Code"> <ItemTemplate> <asp:TextBox ID="SubjectCd" Text='<%# DataBinder.Eval(Container.DataItem, "subject_cd") %>' MaxLength="7" style="TEXT-TRANSFORM: uppercase" runat="server" TabIndex="6" BorderStyle="None"> </asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Mark"> <ItemTemplate> <asp:TextBox ID="Mark" runat="server" Columns="3" MaxLength="3" TabIndex="6" BorderStyle="None"></asp:TextBox> </ItemTemplate> </asp:TemplateColumn> </Columns> <PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle> </asp:datagrid>
in code behind ---------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim constring As String = ConfigurationSettings.AppSettings("GblConnection") oConn = New SqlConnection(constring)
If Not IsPostBack Then bind_grid()
End If
End Sub
----------
Protected Sub bind_grid() Query = "select * from ba_student_detl" adap = New SqlDataAdapter(Query, oConn) Dim ds As DataSet = New DataSet adap.Fill(ds) DataGrid1.DataSource = ds DataGrid1.DataBind() End Sub
---------------- Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged DataGrid1.CurrentPageIndex = e.NewPageIndex bind_grid() End Sub -----------------------
thanks D.Devi
|
| Author: vipul 07 Nov 2009 | Member Level: Diamond | Rating:  Points: 2 |
Hi, it is not possible to manage your previous steps in the data grid because if you go to the next page then you have to bind the datagrid once again and if you want to maintain previous state then you have to store in the datasource table and also in the view state or session then it is possible otherwise not.
Please Rate This Answer If They Helpful
Thanks & Regards Patel Vipul
|