Hi sunil123,
Check this example. now please take its reference and correct your code.
HTML
CS.aspx
Enter Date:<asp:TextBox runat="server" ID="txtDate" />
<br />
<br />
<asp:Button Text="Submit" runat="server" ID="btnSubmit" OnClick="Submit_OnClick" />
Details.aspx
<asp:GridView runat="server" ID="gvDetails" AutoGenerateColumns="false" OnRowCancelingEdit="gvDetails_RowCancelingEdit"
OnRowEditing="gvDetails_RowEditing">
<Columns>
<asp:TemplateField HeaderText="updated_on" SortExpression="updated_on">
<EditItemTemplate>
<asp:TextBox runat="server" ID="TextBox17" Text='<%# Request.QueryString["Date"].ToString() %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label17" runat="server" Text='<%# Bind("Date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="true" />
</Columns>
</asp:GridView>
VB.aspx
Enter Date:<asp:TextBox runat="server" ID="txtDate" />
<br />
<br />
<asp:Button Text="Submit" runat="server" ID="btnSubmit" OnClick="Submit_OnClick" />
VBDetails.aspx
<asp:GridView runat="server" ID="gvDetails" AutoGenerateColumns="false" OnRowCancelingEdit="gvDetails_RowCancelingEdit"
OnRowEditing="gvDetails_RowEditing">
<Columns>
<asp:TemplateField HeaderText="updated_on" SortExpression="updated_on">
<EditItemTemplate>
<asp:TextBox runat="server" ID="TextBox17" Text='<%# Request.QueryString("Date").ToString() %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label17" runat="server" Text='<%# Bind("Date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="true" />
</Columns>
</asp:GridView>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
CS.aspx.cs
protected void Submit_OnClick(object sender, EventArgs e)
{
string datetime = txtDate.Text.Trim();
Response.Redirect("Details.aspx?Date=" + datetime);
}
Details.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.BindGrid();
}
}
private void BindGrid()
{
DataTable dt = new DataTable();
dt.Columns.Add("Date");
dt.Rows.Add(DateTime.Now.ToShortDateString());
this.gvDetails.DataSource = dt;
this.gvDetails.DataBind();
}
protected void gvDetails_RowEditing(object sender, GridViewEditEventArgs e)
{
this.gvDetails.EditIndex = e.NewEditIndex;
this.BindGrid();
}
protected void gvDetails_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
this.gvDetails.EditIndex = -1;
this.BindGrid();
}
VB.Net
VB.aspx.vb
Protected Sub Submit_OnClick(ByVal sender As Object, ByVal e As EventArgs)
Dim datetime As String = txtDate.Text.Trim()
Response.Redirect("VBDetails.aspx?Date=" & datetime)
End Sub
VBDetails.asx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.BindGrid()
End If
End Sub
Private Sub BindGrid()
Dim dt As DataTable = New DataTable()
dt.Columns.Add("Date")
dt.Rows.Add(DateTime.Now.ToShortDateString())
Me.gvDetails.DataSource = dt
Me.gvDetails.DataBind()
End Sub
Protected Sub gvDetails_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
Me.gvDetails.EditIndex = e.NewEditIndex
Me.BindGrid()
End Sub
Protected Sub gvDetails_RowCancelingEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs)
Me.gvDetails.EditIndex = -1
Me.BindGrid()
End Sub