Reputation: 2014
i want to insert a row to a datagridview in c#.net winform, that have one cell (it means merging cells). i use this row as title of later rows. is there any solution to answer this need?
tnx
Upvotes: 0
Views: 1229
Reputation:
Upvotes: 0
Reputation: 121
I'm not sure what you are trying to do, can you provide a little more detail on what you are trying to accomplish, and with some data samples? what version of .net are you targeting?
here is a little bit of code that combines two columns into one column, not sure if this is what you are after.
*.aspx
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateField HeaderText="CombinedHeader">
<ItemTemplate>
<asp:Label ID="lblBreakDown" runat="server" Text='<%# string.Format("{0} ({1})",Eval("Column1"),Eval("Column2") ) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
DataTable dtTemp = new DataTable();
dtTemp.Columns.Add("Column1", typeof(System.String));
dtTemp.Columns.Add("Column2", typeof(System.String));
DataRow drRow1 = dtTemp.NewRow();
drRow1[0] = "Data1";
drRow1[1] = "Data2";
dtTemp.Rows.Add(drRow1);
GridView1.DataSource = dtTemp;
GridView1.DataBind();
}
Upvotes: 1