but it show only one 1st grid data & selection not work
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Purushottam RathorePosted Jun 10, 2010, 7:37 AM
plz try the following code:
Width="100%" ShowFooter="False">
OnCommand="LinkButtonPostName_Command" />
Now bind the first grid as follows:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source = SQLSERVER2005; Initial Catalog = Personal; User ID = sa; Password = wintellect;");
SqlDataAdapter da = new SqlDataAdapter("select * from Category", con);
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
GridViewCategory.DataSource = ds;
GridViewCategory.DataBind();
con.Close();
}
Write the following method for second grid:
public DataSet Getdatasource(object objDRView)
{
if (!object.Equals(objDRView, null))
{
DataRowView dRView = (DataRowView)objDRView;
int CategoryId = int.Parse(dRView["CategoryId"].ToString());
SqlConnection con = new SqlConnection("Data Source = SQLSERVER2005; Initial Catalog = Personal; User ID = sa; Password = wintellect;");
string cmd = "select * from SubCategory where CategoryId=" + CategoryId;
SqlDataAdapter da = new SqlDataAdapter(cmd, con);
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
return ds;
}
else
{
return null;
}
}