ram1217
asked on
Grid question
Hi,
I am trying to create a grid based on the attach file but I am not able to merge the columns 6 to 9 the way it is shown.
Can anyone please help me with this? I am using html tags in C# class
I am attaching the excel file on how my grid should look like.
Grid.xls
I am trying to create a grid based on the attach file but I am not able to merge the columns 6 to 9 the way it is shown.
Can anyone please help me with this? I am using html tags in C# class
I am attaching the excel file on how my grid should look like.
Grid.xls
ASKER
Can you provide me a sample of code on how this can be done based on the file attached?
Ok, I will work on it and try to solve your problem
- Deepak Lakkad
- Deepak Lakkad
hi.. you can do this with this example
I have created ASP.NET page which is very straight forward with only one Button and GridView control on it. Following is the HTML source for the (.aspx) file.
<form id="form1" runat="server">
<asp:button id="Button1" runat="server" onclick="Button1_Click" text="Display Excel Data" />
<br>
<br>
<asp:gridview id="GridView1" runat="server" cellpadding="6" gridlines="None"
bordercolor="#336699" borderstyle="Solid" borderwidth="1px">
<headerstyle backcolor="#336699" font-bold="True" forecolor="White" />
</asp:gridview>
</form>
In the C# code of the button Click event I will connect and read Excel file and then I will bind the data to GridView control. To connect Excel file you need to use Microsoft Jet OLEDB data provider as you can see from the following connection string. The path of the excel file is provided by using ASP.NET DataDirectory feature which points to the App_Data folder in your Website.
string strConn = "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=|DataDirectory|Sear chEngines. xls;Extend ed Properties='Excel 8.0;HDR=Yes;'";
string query = "SELECT * FROM [Sheet1$]";
DataSet excelDataSet = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(query, strConn);
da.Fill(excelDataSet);
GridView1.DataSource = excelDataSet;
GridView1.DataBind();
I hope this will help many of you specially.
I have created ASP.NET page which is very straight forward with only one Button and GridView control on it. Following is the HTML source for the (.aspx) file.
<form id="form1" runat="server">
<asp:button id="Button1" runat="server" onclick="Button1_Click" text="Display Excel Data" />
<br>
<br>
<asp:gridview id="GridView1" runat="server" cellpadding="6" gridlines="None"
bordercolor="#336699" borderstyle="Solid" borderwidth="1px">
<headerstyle backcolor="#336699" font-bold="True" forecolor="White" />
</asp:gridview>
</form>
In the C# code of the button Click event I will connect and read Excel file and then I will bind the data to GridView control. To connect Excel file you need to use Microsoft Jet OLEDB data provider as you can see from the following connection string. The path of the excel file is provided by using ASP.NET DataDirectory feature which points to the App_Data folder in your Website.
string strConn = "Provider=Microsoft.Jet.OL
string query = "SELECT * FROM [Sheet1$]";
DataSet excelDataSet = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(query, strConn);
da.Fill(excelDataSet);
GridView1.DataSource = excelDataSet;
GridView1.DataBind();
I hope this will help many of you specially.
ASKER
Thank you for the code above but I cannot implement this way of adding a button since that is not part of requirement.
Any other way to do this? I need to get this done asap, any help would be great.
Any other way to do this? I need to get this done asap, any help would be great.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you johny_bravo1, the links you sent me worked amazing.
I was able to create the grid and everything looks fine.
Thank you very much for your help!!
I was able to create the grid and everything looks fine.
Thank you very much for your help!!
I think you cannot get this result in Simple GridView, you have to use Repeater control for that
- Deepak Lakkad