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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Purushottam RathoreRank #120 · 18.2K reputationPosted Jun 10, 2010, 3:37 AM EDT
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;
}
}