|
|
Comments and Discussions
|
|
 |

|
Hi,
I'm using this code and think it is fantastic! One thing I can't figure out is how to change the column widths, as I have added many and they are spanning 2 monitors.
Does anyone have an idea?
|
|
|
|

|
hello sir,
parent grid is updated and deleted but i am unable to write the same code in row cancelling and row editing in the nested grid which is child grid.
please help me for this....
protected void gvchild_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView gvtemp = (GridView)sender;
gvUniqueId = gvtemp.UniqueID;
gvEditIndex = e.NewEditIndex;
gvparent.DataBind();
}
this is the code what i wrote...
please help me in this i am not edit the row...
|
|
|
|
|

|
How do you add a search botton and show the nested gridview after search button is clicked?
|
|
|
|

|
I just tested it and have nothing to say but appreciation. Keep up the good work. I am working to implement this on MVC.
|
|
|
|

|
I bind to a datasource for gridview2.
the grid shows up, but shows items for the last item in gridview1 and not the item I click on.
so, if I click on item 6, it shows item 10, click on item 8, it shows for item 10...
Is there a way around this?
|
|
|
|
|

|
can i get this vb.net code, so that i can use it in my project.
i am purely don't know anything about web.
|
|
|
|
|

|
It has all events that i was looking for. Thanks for helping me by this article.
|
|
|
|
|

|
i placed entire code in updatepanel,it's simply merging after every event but working to view the events i have to press + symbol every time to view how to stop merging
Thanks in advance
Naseer
|
|
|
|

|
How do you go about populating the nested data after you delete a row? I added snippets of the code to my code to get the delete to work and when I click the delete link it drops back to the parent grid. I would like the nested grid to stay open.
Is this possible?
Thanks!
Shawn
|
|
|
|

|
Hello Sir,can it possible to n number of child grid in parent grid..my urgent requirement is that parent grid and child grid but child grid must be more than 3/4 grids with full functionality like treeview grid .plz help me out sir..thanx in advance..
|
|
|
|

|
Hello Sir,can it possible to n number of child grid in parent grid..my urgent requirement is that parent grid and child grid but child grid must be more than 3/4 grids with full functionality like treeview grid .plz help me out sir..thanx in advance..
|
|
|
|

|
Hi Satya Kanithi
Thank you very mush!
|
|
|
|

|
Thanks alot its working perfect!! it really helped me alot
|
|
|
|
|
|
|

|
Hi, this article is very usefull for me, there is only 1 problem. I use SQLdata Server & I don't know what parts of code I have to adjust to make it work properly.
Any possible help with this would be appreciated ! Thanks.
|
|
|
|

|
Hi, here's an example:
private DataTable ChildDataSource(string strCustometId, string strSort)
{
using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["Evaluatie"].ConnectionString))
{
conn.Open();
using (SqlDataAdapter a = new SqlDataAdapter("SELECT criteriaid, domeinid, omschrijving FROM criteria WHERE criteria.domeinid=" + strCustometId + " UNION ALL SELECT '" + strCustometId + "','','' FROM criteria WHERE criteria.domeinid=" + strCustometId + " HAVING COUNT(*)=0 " + strSort, conn))
{
DataTable dt = new DataTable();
a.Fill(dt);
return dt;
}
}
}
|
|
|
|

|
This worked very well thanks ! Btw did you find a way or a example on your earlyer question ? The one where you aked for a third Gridview nested ? It might proof usefull to me in the future. Cheers !
|
|
|
|
|

|
Hey, I wasn't able to check your post in time sadly, however you seem to have found a solution to your problem.
I tryed working around your information given on the site. but somehow it ain't working.
Would it be possible for you to send me the files or complete code ?
This might acctually be usefull for my realisations.
Thanks again ! You seem to be knowing better what your doing then me !
|
|
|
|

|
Sure !
The only problem I'm still experiencing is that after every page load, the javascript is reloaded so all the gridviews are collapsed. (For example after editing a row). I haven't figured it out how to solve that...
The gridhowever is working just fine.
You can download it here:
http://gridview.degendt.com/[^]
note: I didn't have the time to translate everything, but I don't think that is necessary. The first grid is called "domein", the second one "Criteria" and the third one "SubCriteria"
Let me know if you need my help !
|
|
|
|

|
I was having the same problem (all the gridviews are collapsed), the only difference with my code was an update panel, after I removed it, it started to work ok.
|
|
|
|

|
I realise this article is 'old' but I was wondering if anyone could supply me a good example with a third, nested gridview? Thanks!
|
|
|
|
|
|

|
Nice Article Satya. Its helping me a lot. Thank you.
|
|
|
|

|
The childgrid gets data but won't display in parent grid???
|
|
|
|

|
I am trying this with a stored proc and not inline sql but for some reason my 1st result is in the parent grid but all my child results are outside of the parent so my expand and contract do not contain the child. In addition the following parent headers are all not formatted like the very first one. I can provide images if anybody can help.
Thanks,
|
|
|
|

|
Hii EveryOne
I would like to say that the article is really great.I learns lot from the article. But i am facing from one problem i have the repeated rows in child grid when second child grid add.Above child grid rows add dynamically in the below child grid.As if i have Id h001 and h002 in first childgrid rows now when second child grid comes which has only h003 Id . But at run time i found h001,h002and h003 in second child grid. h001and h002 comes from the above child grid.
Please suggest me where i am doing wrong.
Thanks
Gaurav Gupta
|
|
|
|

|
Great job and explanation! Clean and easy code. Thanks!
|
|
|
|

|
Your code is fantastic. I have actually modified it to allow for double click row event and other visual asthetics. However, I am not sure why I am receiving a Postback error when I perform the DoubleClick on the row. If I set EnableEventValidation to False, the error goes away. Since this opens us up to possible injection attacks, I want to leave it as True.
I added the following column and programmatically set visible to False.
<asp:ButtonField Text="DoubleClick" CommandName="DoubleClick" />
I added the following code to the bottom of GridView1_RowDataBound event handler:
// Get the LinkButton control in the second cell
LinkButton _doubleClickButton = (LinkButton)e.Row.Cells[1].Controls[0];
// Get the javascript which is assigned to this LinkButton
string _jsDouble =
ClientScript.GetPostBackClientHyperlink(_doubleClickButton, "");
// Add this javascript to the ondblclick Attribute of the row
e.Row.Attributes["ondblclick"] = _jsDouble;
_doubleClickButton.Visible = false;
Then I added the following Render event:
protected override void Render(HtmlTextWriter writer)
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
// validate the controls event
Page.ClientScript.RegisterForEventValidation(row.UniqueID + "$ctl0");
}
}
base.Render(writer);
}
I have been online checking posts for hours and trying various examples but I can't seem to figure out why I receive the following error message:
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
If anyone could help, that would be great! I am not a novice programmer but I am a newbie to ASP.Net. Any help would be appreciated.
Kristin
|
|
|
|

|
Hi Your article simple fine, in additional i want to show some image while sorting the gridview like for ascending show one image,decending show another image same for child gridview also.. have any idea, please let me know..
Regards, Pawan.
|
|
|
|

|
How do I expand and collapse all?
|
|
|
|

|
How do download source files ?
|
|
|
|

|
hi i need to implement a 2checkboxfiled in gridview if one check yes checkboc then der should call a funtion ...example if one click yes than (exit+1)-entry..esle (exit- entry).....so how can i make it .plz help.me.....out...
|
|
|
|

|
Hi, Iam a newbie completly new to .Net .
First i want to say thanks for such a great article , learned a lot from it about Nested gridviews, Expand/Collapse, Edit Update etc.
But I want to the same for Xml Menu Files stored in an Sql Server DB. For the Xml Menu Files created from another Page.
I want to get the Nodes dynamically, i.e. I have to display nested gridviews for more than one Xml Menu File, so I cant bind the nodes statically.
Can you help me pls???
vry urgent....
Regards
Brightsy
|
|
|
|

|
sample OK. but gridview use new table. No Records Bound to the Gridview.
gridview is no display ? (include FooterTemplate).
how to do.
|
|
|
|

|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
OleDbCommandBuilder cmb;
OleDbConnection connection;
OleDbDataAdapter adapter;
DataSet ds;
OleDbCommand command;
public Form1()
{
connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/Hotel.mdb");
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
connection.Open();
command = new OleDbCommand("select *from Banqute_Booking",connection);
adapter= new OleDbDataAdapter(command);
cmb= new OleDbCommandBuilder(adapter);
ds = new DataSet();
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
connection.Close();
}
private void button1_Click(object sender, EventArgs e)
{
connection.Open();
adapter.Update(ds);
connection.Close();
}
private void button2_Click(object sender, EventArgs e)
{
connection.Open();
command = new OleDbCommand("select *from Banqute_Booking where Booking_Date_For=@id", connection);
command.Parameters.Add(new OleDbParameter("@id", dateTimePicker1.Text));
adapter = new OleDbDataAdapter(command);
cmb = new OleDbCommandBuilder(adapter);
ds = new DataSet();
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
connection.Close();
}
}
}
In this code if i am updating my record without filtering the data it's working but if put any condition on my command it give an exception.
Bring me out of it.
|
|
|
|

|
code works but table structure becomes broken after rendering grid.
|
|
|
|

|
Hi,
We are using the NestedGridView, and when we sort on the child grid on any of the columns of the child grid by clicking on them, the parent grid refreshes and the child grid collapses. We need to have the sorting on the child grid independently sorting only records in the child grid and remaining expanded.
We also lose the plus sign for the child grid when sorting the parent grid.
Sincerely,
Sukh
|
|
|
|

|
nice work.
How did you add the 2nd gridview? I mean, do you visually see gridview2 at design time? If not, how would you add the related events to GridView2 such as RowDataBound, RowCommand, SelectedIndexChanged etc?
I tried to get GridView2 out of GridView1 and created all needed events and then put it back in its place, but same I get Compilation Error not recognizing GridView2 events.
See below
Compilation Error
Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
Source Error:
Line 113: Protected Sub GridView2_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView2.RowDataBound
Line 114:
Line 115: End Sub
Anyone, please help.
I am using VB code.
Thanks
ILoveMicrosoft!!
|
|
|
|

|
The sort on the childgrid is not working; nothing happens when I click on the each column header for sort. I uploaded all three files (default.aspx, default.aspx.cs, and the javascript file). Please suggest.
http://www.superboxhost.com/genericfiles/post.txt
|
|
|
|

|
How do I expand and collapse all?
|
|
|
|

|
add this right after the form tag:
<div style="">
<a id="a" href="#" onclick="<%= sbExpandLink.ToString() %>return(false);">[toggle all expansion]</a>
</div>
Add this into the "Variables" region:
protected StringBuilder sbExpandLink = new System.Text.StringBuilder("");
And finally, add this to the end of the "GridView1_RowDataBound" event handler:
sbExpandLink.Append("expandcollapse('div" + ((DataRowView)e.Row.DataItem)["CustomerID"].ToString() + "', 'one');");
|
|
|
|

|
1. I put the div code after the </form>.
2. I put the stringbuilder sbexpandlink in the default.aspx and default.aspx.cs file
3. I added the last code in the gridview1_rowdatabound (I added in addition to the existing code, did not replace with yours).
But not working. Please suggest.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
How to create an all-in-one editable nested GridView in ASP.NET using C#.
| Type | Article |
| Licence | CPOL |
| First Posted | 16 Aug 2007 |
| Views | 301,714 |
| Downloads | 10,073 |
| Bookmarked | 227 times |
|
|