datagrid with template column
Hi,
I have datagrid in my web form(code behind VB.Net).In that i have template coloumn with textbox.whenever i moved to next page and previous page,the data which entered in textbox not visible.i have written databind in form load. can any body give me solution
Thanks
satish
Re: datagrid with template column
Move to next page and previous page, do you mean Paging? If so make sure you are rebinding the DataGrid in PageIndexChanged event...
Re: datagrid with template column
Yes im doing this on pageindex change
dg.CurrentPageIndex = e.NewPageIndex
dg.DataBind()
After writing something on textbox in page one,if go for next and previous the text in textbox not visible.I enable the viewstate also..but same problem.
Re: datagrid with template column
Quote:
Originally Posted by dgsatish
Yes im doing this on pageindex change
dg.CurrentPageIndex = e.NewPageIndex
dg.DataBind()
After writing something on textbox in page one,if go for next and previous the text in textbox not visible.I enable the viewstate also..but same problem.
How/where are you defining DataSource for dg?
Re: datagrid with template column
this is im doing in form load
Dim ds As New DataSet
Dim da As New SqlDataAdapter(strsql, objcon)
da.Fill(ds, "user_verint")
dg.DataSource = ds.Tables("user_verint").DefaultView
If (ds.Tables("user_verint").Rows.Count <> 0) Then
If (Not IsPostBack) Then
dg.DataBind()
End If
Else
Response.Redirect("NoRecords.aspx")
End If
Re: datagrid with template column
VB Code:
'put this on PageLoad
If Not(Page.IsPostBack) then
BindGrid()
End If
'Put this in dg_PageIndexChanged
dg.CurrentPageIndex = e.NewPageIndex
BindGrid()
Private sub BindGrid()
Dim ds As New DataSet
Dim da As New SqlDataAdapter(strsql, objcon)
da.Fill(ds, "user_verint")
dg.DataSource = ds.Tables("user_verint").DefaultView
If (ds.Tables("user_verint").Rows.Count <> 0) Then
dg.DataBind()
End If
End Sub
Re: datagrid with template column
Post back and page index change i am doing but my problem is
I have datagrid in my web form(code behind VB.Net).In that i have template coloumn with textbox.I enterd some text in textbox and moved to next records.when i come back pressing previous link,i am not finding the text which was enterd previously.
Re: datagrid with template column
You wont, whenever you navigate to a new page, all values you have entered will be lost unless you store it or save it to the database..