By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,759 Members | 1,227 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,759 IT Pros & Developers. It's quick & easy.

datagrid on my asp.net platform

P: 1
Hi All,

I hav a datagrid on my asp.net platform..But itz not loading when i execute it...(or run the program...lets say a simplest one),,,,other controls are loading perfectly.....written below is d code....
A quick help will b appreciated...
thx
Shikhar

PROGRAM #####

Expand|Select|Wrap|Line Numbers
  1. using System.Data.SqlClient;
  2. public partial class _Default : System.Web.UI.Page 
  3. {
  4.     SqlDataAdapter da;
  5.    SqlConnection conn;
  6.     SqlCommand cmd;
  7.     DataSet ds = new DataSet();
  8.     protected void Page_Load(object sender, EventArgs e)
  9.     {
  10.        // conn = new SqlCommand("server=.;integrated security=yes;database=shikhar");
  11.         da = new SqlDataAdapter("select * from tr", "server=.;integrated security=yes;database=shikhar");
  12.             if (Page.IsPostBack== false)
  13.         {
  14.            fill();
  15.         }
  16.     }
  17.  
  18.     private void fill()
  19.     {
  20.     da.Fill(ds);
  21.         GridView1.DataSource=ds.Tables[0];
  22.         GridView1.DataBind();
  23.     }
  24.  
  25.     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  26.     {
  27.          String id="";
  28.         GridViewRow gr = GridView1.Rows[e.RowIndex];
  29.         id =gr.Cells[0].Text;
  30.         String del = "DELETE FROM tr WHERE id =" + id;
  31.         conn = new SqlConnection("server=.;integrated security=yes;database=shikhar");
  32.         cmd = new SqlCommand(del,conn);
  33.         conn.Open();
  34.          int r =cmd.ExecuteNonQuery();
  35.         if (r > 0)
  36.         {
  37.             fill();
  38.         }
  39.         conn.Close();
  40.     }
  41.  }
Feb 29 '08 #1
Share this Question
Share on Google+
1 Reply


kenobewan
Expert 2.5K+
P: 4,871
What happens if you just use ds as the datasource?
Mar 1 '08 #2

Post your reply

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