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.....w ritten below is d code....
A quick help will b appreciated...
thx
Shikhar
PROGRAM #####
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.....w ritten below is d code....
A quick help will b appreciated...
thx
Shikhar
PROGRAM #####
Code:
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlDataAdapter da;
SqlConnection conn;
SqlCommand cmd;
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
// conn = new SqlCommand("server=.;integrated security=yes;database=shikhar");
da = new SqlDataAdapter("select * from tr", "server=.;integrated security=yes;database=shikhar");
if (Page.IsPostBack== false)
{
fill();
}
}
private void fill()
{
da.Fill(ds);
GridView1.DataSource=ds.Tables[0];
GridView1.DataBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
String id="";
GridViewRow gr = GridView1.Rows[e.RowIndex];
id =gr.Cells[0].Text;
String del = "DELETE FROM tr WHERE id =" + id;
conn = new SqlConnection("server=.;integrated security=yes;database=shikhar");
cmd = new SqlCommand(del,conn);
conn.Open();
int r =cmd.ExecuteNonQuery();
if (r > 0)
{
fill();
}
conn.Close();
}
}
Comment