.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Dynamic Gridview inside a Dynamic Gridview

Posted By:      Posted Date: October 09, 2010    Points: 0   Category :ASP.Net

If there's a better way to accomplish what I'm attempting I haven't found it yet. That being said, I have create a gridview like the one here, http://www.aspsnippets.com/Articles/Adding-Dynamic-Rows-in-ASP.Net-GridView-Control-with-TextBoxes.aspx . And with some minor tweaking it working great for all my fields, checkboxes, etc. The issue is my last column is another gridview, and I'd like it to function the same. that is, a dynamic gridview inside of a dynamic gridview. I get that I have to create it initially with null values or it won't show up. I guess what I'm having trouble figuring out is instead of go will null data in the parent gridviews column, do I place my blank child gridview. Do I create and bind the child gridview first, or second. Generally just not sure. Also, as far as storing the data from the child gridview goes, will each one need it's own datatable? Thanks for any input, and if you have any suggestions on the whole idea please feel free to let me know ;-)

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlC

View Complete Post

More Related Resource Links

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

Adding Dynamic Rows in GridView with TextBoxes

I decided to write this article because this has been asked so many times before at the forums(http://forums.asp.net) . Basically, this example shows on how to generate a Row in GridView with TextBoxes when clicking a Button that is residing inside a GridView Footer.

Adding Dynamic Rows in GridView with TextBoxex in C#

I decided to write this article because this has been asked so many times before at the forums(http://forums.asp.net) . Basically, this example shows on how to generate a Row in GridView with TextBoxes when clicking a Button that is residing inside a GridView Footer.

gridview help on each dynamic row solve this show values based on all columns

<asp:GridView style="Z-INDEX: 101; LEFT: 1px; POSITION: absolute; TOP: 183px" id="Gridview1" runat="server" Width="613px" Height="127px" ForeColor="Teal" Font-Size="12pt" Font-Names="Palatino Linotype" Font-Bold="True" Visible="False" BorderColor="Transparent" AutoGenerateColumns="false" CellSpacing="2" GridLines="None" OnRowCreated="Gridview1_RowCreated" SelectedIndex="5" ShowFooter="true" OnRowDataBound="Gridview1_RowDataBound"><Columns>  <asp:TemplateField HeaderText="ItemCode"><ItemTemplate> <asp:DropDownList id="DropDownList1" tabIndex=16 runat="server" AutoPostBack="True" DataValueField=" ItemCode " DataTextField=" ItemCode" ></asp:DropDownList></ItemTemplate></asp:TemplateField>  <asp:TemplateField HeaderText="ItemName"><ItemTemplate> <asp:DropDownList id="DropDownList2" tabIndex=16 runat="server" AutoPostBack="True" DataValueField="ItemName" DataTextField="ItemName" ></asp:DropDownList> </ItemTemplate> </asp:TemplateField>  <asp:TemplateField HeaderText="Category"&

Dynamic templatefield disappear during gridview rowcommand

Hi,   I already implemented the dynamic templatefield which will re-created in every postback. Everytime I make a postback in the page I see no problem but when I click my imagebutton inside the gridview then the dynamic templatefield disappear. To double check if it is really gone at all I just select the second page of the gridview using my customize paging using dropdownlist outside the gridview and the templatefield with its correct data reappear again. I already put a variable inside the rowcommand to see if the number of columns are the same with the number of columns the gridview render together with the dynamic templatefield during debugging and it is there but cannot render that templatefield in the client.   Any ideas? 

Dynamic Image Buttons in GridView not doing partial post back

Hi Gurus - Create a gridview with AllowPaging and AllowSorting = true- On page load, I bind it to datasource (in my case a webservice) - On gridview's rowcreated event, I dynamically add image buttons on the header of the grid for sorting (up/down arrows). On header I have column name and the image. I removed the Column name default sorting link. So user can now only click the image button for sorting.-  Call sorting method This works perfectly fine without AJAX. The paging, sorting works fine. Also when I apply AJAX the paging works fine. But the sorting is doing a full post back instead of partial postback. I have my gridview within UpdatePanel and Triggeres is set on gridview sill it doesn't work.ASPX Code<form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Label ID="lblAccount" runat="server" Text="Account #: "></asp:Label> <asp:TextBox ID="txtAccountNumber" runat="server">12203A30</asp:TextBox> <asp:Button ID="cmdGo" runat="server" Text="Go" OnClick="cmdGo_Click" /><br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> &l

Creating dynamic template columns in gridview

how to create dynamic template columns in gridview  . I have writing some of the code but it gives me error The type or namespace name 'GridViewLabelTemplatecould' not be found (are you missing a using directive or an assembly reference?)    I have paste some my code /con.Open();        string strsql = "select ID,CompanyName from tblcompany";               SqlCommand cmd = new SqlCommand();        cmd.CommandType = CommandType.Text;        cmd.CommandText = strsql;        cmd.Connection = con;        SqlDataAdapter adpt = new SqlDataAdapter();        adpt.SelectCommand = cmd;        adpt.Fill(dt);        GridView1.Columns.Clear();        for (int i = 0; i < dt.Columns.Count; i++)        {            TemplateField tf = new TemplateField();            // create the data rows       

What's the difference between a dynamic data project and adding a gridview to a "normal" project?

Hi,I'm having difficulty understanding what dynamic data actually is.There is an option to specifically create a dynamic data project, but I don't understand the difference between this, and just adding some kind of data control, like a gridview or detailsview for example.If someone can help me understand this better I'd really appreciate it.

Gridview - Update with Dynamic SELECT Command?


Hi All...

We created a GridView-based webform with Update using the design wizards - very nice and it works great.  But then we wanted to the ability to create the SELECT command dynamically based on other controls on the page.  We added something like the following to Page_Load()...

            SqlDataSource1.SelectCommand = "SELECT [StationId], [IP] FROM [Stations]";

The GridView populates normally, but the Update no longer works.  It changes the "Edit" link to "Update", gives the user the edit boxes, but when "Update" is clicked it never seems to write the new data to the database.  No error - it just doesnt work...

Any thoughts?  How can we change the SELECT command (and Connection String) dymamically and still retain the Update functionality?

Many thanks - Curt.  Code follows...

    protected void Page_Load(object sender, EventArgs e)
        //  Doesn't work with or without this conditional
        //if (!IsCallback)
            SqlDataSource1.SelectCommand = "SELECT [StationId], [IP] FROM [Stations]";

Embed FLV video with dynamic link in gridview


Hi guys, i need your help.

Currently i'm designing a gridview which could present an flv video file which was located on the database using sql. I use jw player to present the video (http://www.longtailvideo.com/players/jw-flv-player/

Therefore, on the <itemtemplate> i use this code to embed the video:

<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='400' height='300' id='single3' name='single3'>
                                    <param name='movie' value='../data/flashPlayer/player.swf'>
                                    <param name='allowfullscreen' value='true'>
                                    <param name='allowscriptaccess' value='always'>
                                    <param name='wmode' value='transparent'>
                                    <param name='flashvars' value="file=<%# "../data/uploadedData/video/flv" + Eval("videoUrl") %>">

Its a task which had never before... how to get column and design in gridview Dynamic based on value



I need to generate gridview based on table value... let us consider i have in my aspx page one dropdownlist in which i have binded somevale

for example: dropdownlist contain:- Item1

based on Item1 i have three table first table conists A,B,C,D value.

Second Table consist 1,2,3,4,5

Third Table consist (0.5,0.6,0.7) for 1, (0.7,1.0) for 2, (0.6) for 3, (0.8) for 4, and another(0.8) for 5

based on this three table i need to show girdview like this which is below

If its Item2 dropdownlist then row  and column of girdview will be any number based on first,second,third table value for Item2

like this if Item3 dropdownlist then row  and column of girdview will be any number based on first,second,third table value for Item3.

help me to achieve dynamic rows and column based on database value... 

Its a very help if you guys will give me code in asp.net C#....

Dynamic Data GridView style in ie9 isssue


Today I uppgraded my browser to ie9 and run my DynamicData app I'm working on. Strange thing happened. Vertical lines on gridviews can't pick up

their border style (light blue color) from DDGridView class in Site.css.  They all have black color. Did someone experience this issue,any workaround?

It's only vertical gridlines, borders around the table and rowstyle td elements are light blue as it's supposed to be.

How to dynamic generate column in GridView?


Hi All,

I have query data which return variety of DataTable columns,

as I know when the time I bind to GridView, it will populate all columns by default based on the datasource.

due to some reason I do not want to display all data but certain column.

how can I populate it dynamically into GridView? 

should I having multiple gridview with the specific asp:BoundField, then hide and show GridView accordingly?


<asp:GridView ID="GridView1" runat="server" AllowPaging="true" PageSize="10" AutoGenerateColumns="false"



                <asp:BoundField HeaderText="Announcement" DataField="Announcement" HeaderStyle-Width="150px" />

<asp:BoundField HeaderText="Start Date" DataField="StartDate" HeaderStyle-Width="150px" />

<asp:BoundField HeaderText="End Date" DataField="EndDate" HeaderStyle-Width="

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

How To Add calendar control inside a GridView

This article show hot to add calendar control inside a GridView with code in c#

Using ATLAS PopUp Control with Calendar inside the GridView Control

In this video tutorial Mohammad demonstrates how you can access the Calendar control which is displayed using the ATLAS PopUp control inside the GridView control.

RadioButton inside GridView, How to get it work as normal

Did you tried before to drag a RadioButton control inside a Gridivew templatefield, and then you attempt to select these RadioButtons , you will notice that the behavior of RadioButton control will be changed and it will work just like the behavior of checkbox control! the user will be able to select more than one radiobutton in the grid!
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend