I have a gridview written in asp.net (c#), the problem is when try to read data from the textbox return null.
<asp:GridView ID="GridView1" runat="server" DataKeyNames="Week#/Day"
OnRowDataBound="GridView1_RowDataBound"
onrowediting="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating" AutoGenerateColumns="false"
OnPageIndexChanging="GridView1_PageIndexChanging"
OnRowCancelingEdit="GridView1_RowCancelingEdit" AllowPaging="true"
PageSize="4" >
<Columns>
<asp:ButtonField ButtonType="Link" CommandName="Update" text="Update" />
<asp:ButtonField ButtonType="Link" CommandName="Edit" text="Edit"/
<asp:TemplateField HeaderText="Week#/Day" InsertVisible="False"
SortExpression="Week#/Day">
<EditItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%#
Eval("Week#/Day") %>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Saturday" SortExpression="Saturday">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("Saturday") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server"
Text='<%# Bind("Saturday") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sunday" SortExpression="Sunday">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"
Text='<%# Bind("Sunday") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server"
Text='<%# Bind("Sunday") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Monday" SortExpression="Monday">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"
Text='<%# Bind("Monday") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server"
Text='<%# Bind("Monday") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Tuesday" SortExpression="Tuesday">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server"
Text='<%# Bind("Tuesday") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label10" runat="server"
Text='<%# Bind("Tuesday") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Wednesday"
SortExpression="Wednesday">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server"
Text='<%# Bind("Wednesday") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label11" runat="server"
Text='<%# Bind("Wednesday") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I am fill it using datatable on edit call this method
protected void GridView1_RowEditing(object sender,GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindData();
}
and on update call update method
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//Retrieve the table from the session object.
DataTable dt = (DataTable)Session["All_Topics"];
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
TextBox d1, d2, d3, d4, d5;
d1 = (TextBox)row.FindControl("TextBox1");
d2 = (TextBox)row.FindControl("TextBox2");
d3 = (TextBox)row.FindControl("TextBox3");
d4 = (TextBox)row.FindControl("TextBox4");
d5 = (TextBox)row.FindControl("TextBox5");
dt.Rows[row.DataItemIndex]["Saturday"] = d1.Text;
dt.Rows[row.DataItemIndex]["Sunday"] = d2.Text;
dt.Rows[row.DataItemIndex]["Monday"] = d3.Text;
dt.Rows[row.DataItemIndex]["Tuesday"] = d4.Text;
dt.Rows[row.DataItemIndex]["Wednesday"] = d5.Text;
}
the problem is when read data from the textbox it is always null. How can I solve this problem.
Hey please Make sure that do not re-binding the GridView on the PostBack of the page. This may be the cause of problem.
Always bind your grid on page load in side the below code.
if (!Page.IsPostBack ){
// Code to bind the Grid
// BindData();
}
when you are click on Row Update Command it is firstly go to the page load event and on page load if you are not binding your grid like the given manner your grid is rebind and you will get null from text box.
Hope it will helps you.
Related
I have an editable GridView but I would also like to have an add new row functionality, so I made a button using FooterTemplate for all editable fields and set CommandName="AddNew" . Everything looks as expected on the front end, but Add New Row cannot find txtGrantId, txtPotId or txtBudget at all and throws System.NullReferenceException 'Object reference not set to an instance of an object.'. The issue has to be in the code behind, but I am attaching the front end as well. The data source is pretty long but it does call OnRowCommand="gvPotsMoneyGrants_RowCommand"
ASPX
<%--Primary Key LinkId--%>
<asp:TemplateField HeaderText="LinkId" SortExpression="LinkId">
<ItemTemplate>
<asp:Label ID="lblLinkId" runat="server" Text='<%# Eval("LinkId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<%--GrantId--%>
<asp:TemplateField HeaderText="GrantId" SortExpression="GrantId">
<ItemTemplate>
<asp:Label ID="lblGrantIdMain" runat="server" Text='<%#Eval("GrantId") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtGrantId" runat="server" Text='<%#Bind("GrantId") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="inGrantId" Width="120px" runat="server" />
<asp:RequiredFieldValidator ID="vGrantId" runat="server" ControlToValidate="inGrantId" Text="?" ValidationGroup="VG5" />
</FooterTemplate>
</asp:TemplateField>
<%--PotId--%>
<asp:TemplateField HeaderText="PotId" SortExpression="PotId">
<ItemTemplate>
<asp:Label ID="lblPotIdMain" runat="server" Text='<%#Eval("PotId") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPotId" runat="server" Text='<%#Bind("PotId") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="inPotId" Width="120px" runat="server" />
<asp:RequiredFieldValidator ID="vPotId" runat="server" ControlToValidate="inPotId" Text="?" ValidationGroup="VG5" />
</FooterTemplate>
</asp:TemplateField>
<%--Budget--%>
<asp:TemplateField HeaderText="Budget" SortExpression="Budget">
<ItemTemplate>
<asp:Label ID="lblBudgetMain" runat="server" Text='<%#Eval("Budget") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtBudget" runat="server" Text='<%#Bind("Budget") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="inBudget" Width="120px" runat="server" />
<asp:RequiredFieldValidator ID="vBudget" runat="server" ControlToValidate="inBudget" Text="?" ValidationGroup="VG5" />
</FooterTemplate>
</asp:TemplateField>
Code behind
protected void gvPotsMoneyGrants_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
TextBox txtGrantId = (TextBox)gvPotsMoneyGrants.FooterRow.FindControl("txtGrantId");
TextBox txtPotId = (TextBox)gvPotsMoneyGrants.FooterRow.FindControl("txtPotId");
TextBox txtBudget = (TextBox)gvPotsMoneyGrants.FooterRow.FindControl("txtBudget");
string GrantId, PotId, Budget;
GrantId = txtGrantId.Text;
PotId = txtPotId.Text;
Budget = txtBudget.Text;
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddWithValue("GrantId", GrantId);
cmd.Parameters.AddWithValue("PotId", PotId);
cmd.Parameters.AddWithValue("Budget", Budget);
}
}
Please, try the code below.
protected void gvPotsMoneyGrants_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
TextBox inGrantId = (TextBox)gvPotsMoneyGrants.FooterRow.FindControl("inGrantId");
TextBox inPotId = (TextBox)gvPotsMoneyGrants.FooterRow.FindControl("inPotId");
TextBox inBudget = (TextBox)gvPotsMoneyGrants.FooterRow.FindControl("inBudget");
string GrantId, PotId, Budget;
GrantId = inGrantId.Text;
PotId = inPotId.Text;
Budget = inBudget.Text;
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddWithValue("GrantId", GrantId);
cmd.Parameters.AddWithValue("PotId", PotId);
cmd.Parameters.AddWithValue("Budget", Budget);
}
}
I am currently developing an online shopping cart project.
I would like the program to display the GetTotal() in a label outside of the GridView.
<asp:Content ID="Content1" ContentPlaceHolderID="C1" Runat="Server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" ShowFooter="true" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" Width="832px" >
<Columns>
<asp:TemplateField HeaderText="Product Image">
<ItemTemplate>
<asp:Image ImageUrl='<%# "../" + Eval("Product_Image") %>' runat="server" Height="100px" Width="100px"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product Series">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Product_Series") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product Name">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#Eval("Product_Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product Price">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%#Eval("Product_Price") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product Quantity">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%#Eval("Product_Quantity") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%#Eval("Product_Quantity") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
Total Amount:
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Price">
<ItemTemplate>
<%# GetUnitPrice(Decimal.Parse(Eval("Product_Price").ToString())*Decimal.Parse(Eval("Product_Quantity").ToString())).ToString("N2") %>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="l6" runat="server" Text=' <%# GetTotal().ToString("N2") %>'></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="true"/>
<asp:CommandField ShowDeleteButton="true"/>
</Columns>
</asp:GridView>
All values in the GridView are passed on via session from another page, excluding Price and TotalUnitPrice, where calculations are carried out in the script below:
<script runat="server">
decimal TotalUnitPrice;
decimal GetUnitPrice(decimal Price)
{
TotalUnitPrice += Price;
return Price;
}
decimal GetTotal()
{
return TotalUnitPrice;
}
</script>
Any ideas on how to do this? The reason is that I would like the program to obtain the value of GetTotal()via the label and charge the user based on it.
Your GetTotal() in binding in GridView footer Label 16 so you can get it from there and set to outside Label:
// check if GridView is not empty
if (GridView1.Rows.Count != 0)
{
string total = ((Label)GridView1.FooterRow.FindControl("16")).Text;
LabelOutside.Text = total;
}
I am trying to select a row from a gridview by using a select button link but when I click on the button, it doesn't call that C# method. So, I am wondering what could I be doing wrong. Please help me out. Thanks
form.aspx-
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
OnRowEditing="OnRowEditing" OnRowCancelingEdit="OnRowCancelingEdit"
OnRowUpdating="OnRowUpdating" OnRowDeleting="OnRowDeleting" EmptyDataText="No records has been added." Height="72px" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="723px">
<Columns>
<asp:TemplateField HeaderText="Title" ItemStyle-Width="150">
<ItemTemplate>
<asp:Label ID="lbltitle" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txttitle" runat="server" Text='<%# Eval("Title") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle Width="150px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Subtitle" ItemStyle-Width="150">
<ItemTemplate>
<asp:Label ID="lblsubtitle" runat="server" Text='<%# Eval("Subtitle") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtsubtitle" runat="server" Text='<%# Eval("Subtitle") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle Width="150px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Content" ItemStyle-Width="150">
<ItemTemplate>
<asp:Label ID="lblContent" runat="server" Text='<%# Eval("Content") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtContent" runat="server" Text='<%# Eval("Content") %>'></asp:TextBox>
</EditItemTemplate>
<ItemStyle Width="150px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" Text="SELECT" CommandName="MyCustomCommand" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
NewsFeedDemo.cs
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("MyCustomCommand"))
{
GridViewRow clickedRow = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow;
Label lblID = (Label)clickedRow.FindControl("lblID");
}
}
please use this OnRowCommand="GridView1_RowCommand"
<asp:LinkButton ID="lnkbedit" runat="server" CommandName="MyCustomCommand" CommandArgument='<%#Eval("id") %>'>Edit</asp:LinkButton>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
}
}
You use the Method GridView1_RowCommand, but it is not bound to GridView1. You need to add OnRowCommand to the GridView.
<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_RowCommand">
I'm trying to add a data-th in a gridView but I don't know how, this attribute is added in a td
Something like this
<tr>
<td data-th="Movie Title">Star Wars</td>
<td data-th="Genre">Adventure, Sci-fi</td>
<td data-th="Year">1977</td>
<td data-th="Gross">$460,935,665</td></tr>
This is my asp.net code
I tried add data-th in the item template and the Templatefield but it isn't working
<asp:GridView ID="CerrTick" AllowPaging="true" PageSize="15" Width="100%" class="rwd-table" OnPageIndexChanging="CerrTick_PageIndexChanging" runat="server" AutoGenerateColumns="false" OnSelectedIndexChanged="CerrTick_SelectedIndexChanged" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnC" CommandName="Select" class="button prefix bom" runat="server" Text="Seleccionar" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="N° ticket">
<ItemTemplate >
<asp:Label ID="N_Tick" runat="server" Text='<%# Eval("N° ticket") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Tecnico">
<ItemTemplate>
<asp:Label ID="Tec" runat="server" Text='<%# Eval("Tecnico") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Empresa">
<ItemTemplate>
<asp:Label ID="Emp" runat="server" Text='<%# Eval("empresa") %>'></asp:Label>
<asp:Label ID="id_ticket" runat="server" Text='<%# Eval("id_ticket") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Servicio">
<ItemTemplate>
<asp:Label ID="serv" runat="server" Text='<%# Eval("servicio") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Use Code behind RowDataBound
protected void CerrTick_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TableCellCollection cell = e.Row.Cells;
cell[0].Attributes.Add("data-th", "Movie Title");
cell[1].Attributes.Add("data-th", "Genre");
cell[2].Attributes.Add("data-th", "Year");
cell[3].Attributes.Add("data-th", "Gross");
}
}
If you want to avoid doing it in the code behind, you could build the table using a ListView or Repeater and dynamically assign the data attribute. I'm doing something similar, although the data attribute is assigned to the label inside the gridview rather than the cell itself.
<asp:Label ID="Label1" runat="server" Text='<%#Eval("value") %>' data-frequency='<%#Eval("frequency") %>' />
When the user changes the text in the textbox's in the edit template and clicks update, when I try to grab those new values it still is graving the old value of the text box.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="CompanyID" CellPadding="4"
GridLines="None" Width="1079px" ForeColor="#333333"
OnRowCancelingEdit="GridView1_RowCancelling"
OnRowUpdating="GridView1_RowUpdating"
OnRowEditing="GridView1_RowEditing">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
CommandName="Update" CommandArgument='<%# Eval("CompanyID") %>' Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Issue Date">
<ItemTemplate>
<asp:Label runat="server" ID="IssueDate" Text='<%#Eval("IssueDate") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtIssueDate" Text='<%#Eval("IssueDate") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Notice Intent Response Due">
<ItemTemplate>
<asp:Label runat="server" ID="NoticeIntentResponseDue" Text='<%#Eval("NoticeIntentResponseDue") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtNoticeIntentResponseDue" Text='<%#Eval("NoticeIntentResponseDue") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Deadline For Questions">
<ItemTemplate>
<asp:Label runat="server" ID="DeadlineForQuestions" Text='<%#Eval("DeadlineForQuestions") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtDeadlineForQuestions" Text='<%#Eval("DeadlineForQuestions") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Bids Due">
<ItemTemplate>
<asp:Label runat="server" ID="BidsDue" Text='<%#Eval("BidsDue") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtBidsDue" Text='<%#Eval("BidsDue") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Shortlist Notice">
<ItemTemplate>
<asp:Label runat="server" ID="ShortlistNotice" Text='<%#Eval("ShortlistNotice") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtShortlistNotice" Text='<%#Eval("ShortlistNotice") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Final Selection">
<ItemTemplate>
<asp:Label runat="server" ID="FinalSelection" Text='<%#Eval("FinalSelection") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtFinalSelection" Text='<%#Eval("FinalSelection") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false" HeaderText="CompanyID">
<ItemTemplate>
<asp:Label runat="server" ID="CompanyID" Text='<%#Eval("CompanyID") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
The update button calls this function:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int key = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
Label CompanyID = (Label)GridView1.Rows[e.RowIndex].FindControl("txtCompanyID");
TextBox thisIssueDate = (TextBox)(GridView1.Rows[e.RowIndex].FindControl("txtIssueDate"));
TextBox NoticeIntentResponseDue = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtNoticeIntentResponseDue");
Response.Write(NoticeIntentResponseDue.Text + " " + thisIssueDate.Text);
Response.End();
TextBox DeadlineForQuestions = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDeadlineForQuestions");
TextBox BidsDue = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtBidsDue");
TextBox ShortlistNotice = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtShortlistNotice");
TextBox FinalSelection = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtFinalSelection");
}
The response is showing me that the value being grabbed is still the origonal text value of the box. Not what you typed into the box.
In your grid view row updating event add the following condition
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
if (e.Row.RowState == DataControlRowState.Edit )
{
int key = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
Label CompanyID = (Label)GridView1.Rows[e.RowIndex].FindControl("txtCompanyID");
TextBox thisIssueDate = (TextBox)(GridView1.Rows[e.RowIndex].FindControl("txtIssueDate"));
TextBox NoticeIntentResponseDue = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtNoticeIntentResponseDue");
Response.Write(NoticeIntentResponseDue.Text + " " + thisIssueDate.Text);
Response.End();
TextBox DeadlineForQuestions = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDeadlineForQuestions");
TextBox BidsDue = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtBidsDue");
TextBox ShortlistNotice = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtShortlistNotice");
TextBox FinalSelection = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtFinalSelection");
}
}
Update:
the problem looks like that you have also bind your Edit Item template columns with the data from data table, and when you are getting the data in the code behind you are not getting the updated data which the user updates in edit mode and u still getting the old data. If you remove the Binding from the Edit Item Template feilds then your code will work.
I figured it out, Derek was right. It had to do with the Binding Data on postback in page load. I binded the data every time instead of just the first time. Thanks