468,758 Members | 2,086 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,758 developers. It's quick & easy.

datagrid on my asp.net platform

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
1 820
kenobewan
4,871 Expert 4TB
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.

Similar topics

reply views Thread by d_grantham | last post: by
2 posts views Thread by Dimitris Pantazopoulos | last post: by
reply views Thread by d_grantham | last post: by
2 posts views Thread by Frank | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.