I'm wondering if the same thing can be done for the following dynamically
data1 | data11 | data111
| data112
| data 12 | data 121
| data13 | data 131
| data 132
data2 | data21 | data211
| data212
| data 22 | data 221
| data23 | data 231
| data 232
and this gridview will be built dynamically. I mean that the first thing will be shown to the user is the first row with only one cell in each column and within that cell there is a button called ADD
to split that cell into two. to have finally the previouse grid...
I would be more than greatfull if you can help me with that..
I found the soultion what you gave is worth, but i don't want to increase the rowspan, instead i need to make the cell visible to 'false'. And on mouseover i need to highlight the entire <tr> .
I wanted to do something similar and yr code helped. But there is something additional I want to do and that is to retrieve data from the merged cells. The structure below is my grid structure. Now when the user clicks edit I get the index of the row and
the retrieve contents of the row. For the first row I can retrieve all data but when the edit on the second row is clicked, I get an error tht the cell is missing that is because in your code u remove the cells. What I want to know is how do I retrieve data
of each row.
You could try something like this. This example was checks for the value in the first column when a row is selected, but you could do something similar with the edit row. I started at the selected row, then searched through the rows (moving up the table)
until a row is found with the right number of cells, then grab the value.
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int index = GridView1.SelectedIndex;
int columnCount = GridView1.Columns.Count;
for (int i = index; i >= 0; i--)
{
GridViewRow row = GridView1.Rows[i];
int cellCount = row.Cells.Count;
if (cellCount == columnCount)
{
Label1.Text = row.Cells[0].Text;
break;
}
}
}
Hope that helps.
Aaron
Don't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved so everyone will know you have been helped.
I have a gridview which is bound to a dataset. The girdview has an item template which has imagebuttons viz. "up", "Down". When clicked the sequence of the row needs to be changed. Eg: If the 3rd row's 'Up' button is clicked, this
row should now be positioned as the 2nd row and the 2nd row should now be the 3rd. Also the this needs to be updated to database.
Webmaster_Vo...
Member
186 Points
86 Posts
Re: Merge Cell in GridView
Jan 07, 2007 08:23 AM|LINK
Take a look at this website, http://www.volkanakbas.com/?page_id=4
I had the same problem, and after a while came up with the solution I have on the website.
Heidi
Member
2 Points
1 Post
Re: Merge Cell in GridView
Jan 15, 2007 06:05 AM|LINK
Hi,
I'm wondering if the same thing can be done for the following dynamically
data1 | data11 | data111
| data112
| data 12 | data 121
| data13 | data 131
| data 132
data2 | data21 | data211
| data212
| data 22 | data 221
| data23 | data 231
| data 232
and this gridview will be built dynamically. I mean that the first thing will be shown to the user is the first row with only one cell in each column and within that cell there is a button called ADD
to split that cell into two. to have finally the previouse grid...
I would be more than greatfull if you can help me with that..
Best Regards,
Heidi
m_ganish
Member
65 Points
22 Posts
Re: Merge Cell in GridView
Jan 17, 2007 08:44 PM|LINK
Hi,
I found the soultion what you gave is worth, but i don't want to increase the rowspan, instead i need to make the cell visible to 'false'. And on mouseover i need to highlight the entire <tr> .
data1 data1 data1 data1
data1 data1 data1
data1 data1 data1
data2 data2 data2 data2
data3 data3 data3 data3
data3 data3 data3
data3 data3 data3
Thanks in advance
Ganesh
baghzaad
Member
16 Points
8 Posts
Re: Merge Cell in GridView
Jan 31, 2007 06:30 AM|LINK
Hi,
I wanted to do something similar and yr code helped. But there is something additional I want to do and that is to retrieve data from the merged cells. The structure below is my grid structure. Now when the user clicks edit I get the index of the row and the retrieve contents of the row. For the first row I can retrieve all data but when the edit on the second row is clicked, I get an error tht the cell is missing that is because in your code u remove the cells. What I want to know is how do I retrieve data of each row.
data1 data1 data1 data1 data1 edit
data1 data1 edit
data1 data1 edit
data1 data1 data1 data1 data1 edit
data1 data1 edit
data1 data1 edit
data1 data1 edit
data1 data1 edit
data1 data1 data1 data1 data1 edit
data1 data1 edit
data1 data1 edit
data1 data1 edit
agolden
Star
7893 Points
1060 Posts
Re: Merge Cell in GridView
Feb 01, 2007 01:18 AM|LINK
You could try something like this. This example was checks for the value in the first column when a row is selected, but you could do something similar with the edit row. I started at the selected row, then searched through the rows (moving up the table) until a row is found with the right number of cells, then grab the value.
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int index = GridView1.SelectedIndex; int columnCount = GridView1.Columns.Count; for (int i = index; i >= 0; i--) { GridViewRow row = GridView1.Rows[i]; int cellCount = row.Cells.Count; if (cellCount == columnCount) { Label1.Text = row.Cells[0].Text; break; } } }Hope that helps.
Aaron
baghzaad
Member
16 Points
8 Posts
Re: Merge Cell in GridView
Feb 03, 2007 05:27 AM|LINK
Hi Aaron,
I have used the same logic as yr code and it works.
Thanks,
Baghzaad
Nirupa
Member
2 Points
1 Post
Re: Merge Cell in GridView
Feb 07, 2007 02:08 PM|LINK
Hello,
If the cells to be merged are hyperlinkfieds like
Item 1 | Delivery | 1 | 2 | 3
Item 1 | Produce | 1 | 2 | 3
Item 1 | Inventory | 1 | 2 | 3
Now grid display has to look like :
Item 1 | Delivery | 1 | 2 | 3
| Produce | 1 | 2 | 3
| Inventory | 1 | 2 | 3
Is there a way to do it?
baghzaad
Member
16 Points
8 Posts
Re: Merge Cell in GridView
Feb 09, 2007 09:41 AM|LINK
Use the HyperLinkField instead of BoundField. For example <asp:BoundField DataField="ID" HeaderText= "ID"> can be converted to hyper link
<
asp:HyperLinkField HeaderText="ID" Text="<%# Eval("ID") %>" DataNavigateUrlFields="ID" DataNavigateUrlFormatString="~/SomePage.aspx?id={0}" />ReeveBoy
Member
2 Points
1 Post
Re: Merge Cell in GridView
Feb 22, 2007 07:37 PM|LINK
agolden, you are simply amazing ... this code is really top notch programming ... thanks a bunch!![Yes]
m_ganish
Member
65 Points
22 Posts
GridView Re-Sequencing - Urgent !!!
Mar 10, 2007 01:56 PM|LINK
Hi,
I have a gridview which is bound to a dataset. The girdview has an item template which has imagebuttons viz. "up", "Down". When clicked the sequence of the row needs to be changed. Eg: If the 3rd row's 'Up' button is clicked, this row should now be positioned as the 2nd row and the 2nd row should now be the 3rd. Also the this needs to be updated to database.
Is there any way this can be done?
Any help will be of great use!
Thanks ...
</div>Ganesh