473,395 Members | 1,975 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,395 software developers and data experts.

cannot read gridview control.

sir,

i use gridview where all date are retrieve from sql database,i use templete field and there is two textbox , i want when we change the value of textbox which is inside a gridview the value is changed when we click the save button...........
plese help me

page load event
Expand|Select|Wrap|Line Numbers
  1.  if (!IsPostBack)
  2.         {
  3.             string query = Request.QueryString["id"].ToString();
  4.  
  5.             SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["discussionForum"].ConnectionString);
  6.             con.Open();
  7.             SqlCommand cmd = new SqlCommand("SELECT  tblReguser.photo, tblReguser.username,tblComment.id, tblComment.timestamp,tblComment.description,tblComment.relevance FROM tblRegUser CROSS JOIN tblComment WHERE (tblComment.topic_id = @id and tblComment.user_id=tblReguser.id and tblComment.status='0')", con);
  8.             cmd.Parameters.AddWithValue("@id", query);
  9.             SqlCommand cmd1 = new SqlCommand("SELECT  tblReguser.photo, tblReguser.username,tblComment.id, tblComment.timestamp,tblComment.description,tblComment.relevance FROM tblRegUser CROSS JOIN tblComment WHERE (tblComment.topic_id = @id and tblComment.user_id=tblReguser.id and tblComment.status='1')", con);
  10.             cmd1.Parameters.AddWithValue("@id", query);
  11.             SqlDataAdapter adp = new SqlDataAdapter(cmd1);
  12.             DataSet ds = new DataSet();
  13.             adp.Fill(ds);
  14.             GridView3.DataSource = ds;
  15.             GridView3.DataBind();
  16.             SqlDataReader rdr = cmd.ExecuteReader();
  17.             GridView1.DataSource = rdr;
  18.             GridView1.DataBind();
  19.  
  20.             con.Close();
  21.         }
on button click
Expand|Select|Wrap|Line Numbers
  1.  
  2.      protected void saveunblock_Click(object sender, EventArgs e)
  3.     {
  4.  
  5.         Button lnk = sender as Button;
  6.         string a = lnk.CommandArgument;
  7.         foreach (GridViewRow row in GridView1.Rows)
  8.         {
  9.             if (row.RowType == DataControlRowType.DataRow)
  10.             {
  11.                 TextBox t = (TextBox)row.FindControl("t2");
  12.                 CheckBox c = (CheckBox)row.FindControl("c2");
  13.                 string a1 = System.DateTime.Now.ToString();
  14.                 string myvalue = (string)Session["mykey"];
  15.                 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["discussionForum"].ConnectionString);
  16.                 con.Open();
  17.                 if (c.Checked == true)
  18.                 {
  19.                     SqlCommand cmd = new SqlCommand("update tblComment set status='0' where id=@id", con);
  20.                     cmd.Parameters.AddWithValue("@id", a);
  21.                     cmd.ExecuteNonQuery();
  22.                     con.Close();
  23.                     Response.Redirect("admintopic.aspx");
  24.                 }
  25.             }
  26.         }
  27.     }
Oct 10 '11 #1
0 1289

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

Similar topics

0
by: ABC | last post by:
How to custom gridview control (modify column templates) if it derived from web user control? I have a web user control which contains one gridview control. Then I derived web user control to...
3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
3
by: adam222 | last post by:
hello, i have a web-form with a GridView control, i wanted to update & delete, using the AutoGenerateEditButton. when i used it with sqlDataSource (executing SP in the DB) it works like a...
4
by: GregG | last post by:
Greetings, I have been working with the new GridView control, and while figuring out most of it's idiosyncrasies on my own, have stumbled upon a problem I cannot seem to resolve. We have...
0
by: Groove | last post by:
I've noticed something that's come up twice today alone. In ASP.NET 1, I could reference and use a control's property if the control was set to readonly or if it was set to visible = false. Such...
0
by: John Smith | last post by:
ASP.Net 2.0 / C# / IIS 6 I have 2 pages. The master page consists of a tabbed menu created using the Menu and MultiView controls. Something like this: ...
0
by: Borked Pseudo Mailed | last post by:
Hi, I have a Datagrid with template columns (TextBox and Radiolist in them). The ViewState seems to work but I'm unable to access the values of the controls in the Datagrid at Page_Load(). The...
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...
1
bagrigsb
by: bagrigsb | last post by:
My project is fairly simple, since I am a relative noobie to VB.NET. Using a Windows Form with a Menu bar and a Gridview control, I have bound data to the GridView from an MS Access 2000 database...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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.