Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
while saving and binding data to gridview the code is fine.but while updating the datatable is filled with while i binded.no updation values are getting to datatable
my code as below

What I have tried:

int rowIndex = 0;

if (ViewState["CurrentTable"] != null)
{

DataTable dt = (DataTable)ViewState["CurrentTable"];

if (dt.Rows.Count <=5)
{

for (int i = 0; i < dt.Rows.Count; i++)
{

DropDownList box1 = (DropDownList)GridView1.Rows[rowIndex].Cells[1].FindControl("DropDownList1");
TextBox box2 = (TextBox)GridView1.Rows[rowIndex].Cells[2].FindControl("TextBox2");
TextBox box3 = (TextBox)GridView1.Rows[rowIndex].Cells[3].FindControl("TextBox3");
TextBox box4 = (TextBox)GridView1.Rows[rowIndex].Cells[4].FindControl("TextBox4");
TextBox box5 = (TextBox)GridView1.Rows[rowIndex].Cells[5].FindControl("TextBox5");
TextBox box6 = (TextBox)GridView1.Rows[rowIndex].Cells[6].FindControl("TextBox6");
box1.Text = dt.Rows[i]["UNITS"].ToString();

box2.Text = dt.Rows[i]["CONVERSION"].ToString();

box3.Text = dt.Rows[i]["BARCODE"].ToString();

box4.Text = dt.Rows[i]["RATE 1"].ToString();

box5.Text = dt.Rows[i]["RATE 2"].ToString();

box6.Text = dt.Rows[i]["PRINT TEXT"].ToString();
rowIndex++;

}

}

}
Posted
Comments
Dotnet_Dotnet 22-Jan-18 1:40am    
sir first clear the rows and again load
from data table
Member 13636078 22-Jan-18 5:34am    
DataTable dt = (DataTable)ViewState["CurrentTable"];
this is loaded with bind values how i fetch new values
Karthik_Mahalingam 24-Jan-18 9:35am    
Tip: use  Reply   button to post comments/query , so that the user gets notified and respond to your text.
Foothill 22-Jan-18 10:52am    
How are you getting your values to the grid view? Are you manually setting each value or using XAML XPath binding. If so, how are your bindings defined. They should be written like:
<GridViewColumn Header="Units">
<gridviewcolumn.celltemplate>
<datatemplate>
<TextBlock Text="{Binding Path=Units, Mode=OneWay}"/>


Richard Deeming 23-Jan-18 13:21pm    
The question is tagged as "ASP.NET", and the code uses ViewState, so I don't think XAML bindings would come into it. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900