473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

retrieve hidden data from gridview

1
i have to retrieve hidden data from gridview.
hidden data is Usr_No. then i need to update the record based on that condition. now i am getting the hidden data. but only first record is updating.when i am trying to update next records error message is showing like Object reference not set to an instance of an object.


my code is

protected void grdCandidate_Update(object sender, GridViewUpdateEventArgs e)
{
try
{

SqlConnection con = new SqlConnection(connStr);
con.Open();
foreach (GridViewRow row in grdCandidate.Rows)
{
int index = e.RowIndex;
int pageindex = grdCandidate.PageIndex;
int pagecount = grdCandidate.PageSize;
int selectedindex = (pageindex) * (pagecount) + index;
DataSet ds2 = (DataSet)ViewState["Data"];
string usr_sno = ds2.Tables[0].Rows[selectedindex]["usr_sno"].ToString();
//string Round_Desg = ((DropDownList)row.FindControl("ddlStatus")).Selec tedItem.Value;
string Round_Desg = ((DropDownList)row.FindControl("ddlStatus")).Selec tedItem.Value;
Response.Write(Round_Desg);

string sqlUpdate = "update TB_NISI_Interviewdetails set Round_Desg=@Round_Desg where usr_sno=@usr_sno";
SqlCommand cmd = new SqlCommand(sqlUpdate, con);
//cmd.Parameters.AddWithValue("@Company_Name", ddlCompanyName.SelectedItem.Text);
//cmd.Parameters.AddWithValue("@inter_date", txtDate.Text);
cmd.Parameters.AddWithValue("@Round_Desg", Round_Desg);
cmd.Parameters.AddWithValue("@usr_sno", usr_sno);
cmd.ExecuteNonQuery();
con.Close();
BindData();
}
}
catch (Exception ex)
{
string a = ex.ToString();
}
}

plz help me.
Aug 20 '07 #1
1 1433
kenobewan
4,871 Expert 4TB
Welcome to TSDN. I cant find "hidden data is Usr_No", do you mean usr_sno?
Aug 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Nick | last post by:
For some reason, why does ASP.net only see variables that are 'DISPLAYED' inside a datagrid? Even if the Field is Databound, I cannot post the variable or use it in an updatecommand... it has to...
2
by: Mark Rae | last post by:
Hi, See the following: http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic38190.aspx This was a particularly useful feature of the old DataGrid control which seems to...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
8
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i have a GridView and a hidden field : <asp:TemplateField Visible=false > <ItemTemplate > <asp:HiddenField Value="<%#Eval("isActive")%>" id="hidIsActive" runat=server /> </ItemTemplate>...
9
by: Mel | last post by:
I have 10 columns total. 3 of them are invisible. The rest are read- only BoundFields, 3 of which are editable fields using TemplateFields. Upon editing, I want to validate what the user enters...
3
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I am trying to read hidden data from a gridview control. This works if the data is visible but if the column is not visible it does not return anything, thanks. Int32 itemp =...
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
In the code below the first line works to read data from the gridview control but the second line the ltest label is null. The very first column of the grid is a bound data item that I converted...
0
by: E. Kwong | last post by:
In a Gridview control, I have several BoundFields, and also a couple of TemplateFields. In the Rowupdating event, I try to retrieve one of the BoundFields (i.e. 4th column of the Gridview...
14
by: agamoto | last post by:
hello guys, i don't know if this is the right tread to post but i have the following problem: i've built a dynamic gridview in run time because the gried values (columns, headers, etc) are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.