View Single Post
  #1 (permalink)  
Old August 25th, 2009, 03:23 AM
vamshidhar vamshidhar is offline
Authorized User
Points: 91, Level: 1
Points: 91, Level: 1 Points: 91, Level: 1 Points: 91, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Post gridview binding

hi,

my gridview is not binding..
I have taken Dropdownlist in rowdatabound event when i click the add button the grid should be added.but my grid is not binding...
Code:
    protected void grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string s2 = "select subDivisionName from Tbh_SubDivsionMaster";
            SqlDataAdapter ada = new SqlDataAdapter(s2, con);
            DataSet ds = new DataSet();
            ada.Fill(ds);
            DropDownList ddl1 = (DropDownList)e.Row.FindControl("ddl1");
            ddl1.DataSource = ds;
            ddl1.DataTextField = "subDivisionName";
            ddl1.DataBind();
        }


    }


 protected void btnadd_Click(object sender, EventArgs e)
    {

         if (Request.QueryString["uid"] != "")
        {

            grid1.DataSource = ds;
            grid1.DataBind();

         }
     }
these is my source code
HTML Code:
 <asp:GridView ID="grid1"  runat="server" Width="750px" OnRowDataBound="grid1_RowDataBound"  AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None"     >
                               <Columns>
                                 <asp:TemplateField>
                                      <HeaderTemplate >
                                        <asp:Label ID="hd1" runat="server" Text="SubDivisionName"> </asp:Label>
                                      </HeaderTemplate>
                                      <ItemTemplate>
                                            <asp:DropDownList ID="ddl1"   runat="server" DataTextField="subDivisionName" AutoPostBack="true" OnSelectedIndexChanged="ddl1_SelectedIndexChanged1" >
                                            
                                            </asp:DropDownList>
                                        </ItemTemplate>
                                 </asp:TemplateField>
</asp:GridView>