Click here to Skip to main content
12,630,137 members (26,695 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#3.0 C# ASP.NET
I have a dynamic gridview with rows and i want to perform edit record in with in the gridview.

Note: I am not creating columns for gridview

how to do this
Posted 7-Feb-13 0:34am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,

Go with this link learn carefully your answer is here is to create text controls like objects in gridview in asp.net :

http://www.aspdotnet-suresh.com/2011/02/how-to-inserteditupdate-and-delete-data.html[^]


Best of Luck!
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Your link is ok,I want create dropdown with data in dynamic gridview
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            onrowdatabound="GridView1_RowDataBound1">
            <Columns>
                <asp:BoundField DataField="CODE" HeaderText="CODE" />
                <asp:BoundField DataField="REFCODE" HeaderText="REFCODE" />
            <asp:TemplateField>
            <ItemTemplate>
             <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
                    onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="200px">
                </asp:DropDownList>
            </ItemTemplate>
            </asp:TemplateField>
                 </Columns>
</asp:GridView>
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
 
public partial class Default3 : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("--------------------------------");
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand(" write your query", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            con.Close();
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
 
    }
    protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            con.Open();
            var ddl = (DropDownList)e.Row.FindControl("DropDownList1");
            int CountryId = Convert.ToInt32(e.Row.Cells[0].Text);
            SqlCommand cmd = new SqlCommand(" write your query ", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            ddl.DataSource = ds;
            ddl.DataTextField = "xxxxx";
            ddl.DataValueField = "xxxxx";
            ddl.DataBind();
            con.Close();
        }
    }
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100