First, Here is a little fiddle to represent my gridview.
I have a gridview where I've merged the cells on some rows. I then need to be able to get the data from both cells that hasn't been merged and cells that has been merged.
So I have a OnRowCommand that takes commandArgument <%#Eval("col3")%>
. This works great for the rows that hasn't had it's cells merged, But for the rows with longcell
It wont work. I've also tried <%#Eval("col2")%>
with no success.
here is the gridview code (simplified):
<asp:GridView ID="myGridview" runat="server" AutoGenerateColumns="false"
OnRowCommand="myGridview_RowCommand">
<Columns>
<asp:BoundField DataField="col1" HeaderText="col1" />
<asp:BoundField DataField="col2" HeaderText="col2" />
<asp:BoundField DataField="col3" HeaderText="col3" />
<asp:TemplateField>
<HeaderTemplate>
Actions
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="imbEdit" runat="server" ImageUrl="~/css/images/Edit.png" Width="16" CommandName="wEdit" CommandArgument='<%#Eval("col3")%>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
here is where I merge the cells:
foreach (int i in rowIndexes)
{
myGridview.Rows[i].Cells[1].ColumnSpan = 2;
myGridview.Rows[i].Cells.RemoveAt(2);
}