as now i am using grid in my application: my grid code is below.
pls help me to change grid to html table
ShowFooter="True" EmptyDataText="No Records found !!"
BackColor="White" BorderColor="#CC9966" BorderStyle="None"
BorderWidth="1px" >
<%# Eval("ref_id") %>
<%# Eval("category") %>
<%# Eval("subcategory")%>
<%# Eval("oid")%>
" target="_search"><%# Eval("up_name")%>
<%# Eval("keyword")%>
<%# Eval("demo1")%>
SelectCommand="SELECT [ref_id],[category],[subcategory],[oid],[up_name],[keyword,[demo1] from Fileupload " FilterExpression ="{0} LIKE '%{1}%'">
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jul 2, 2012, 9:24 AM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Search_Display_in_table._Default" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Search_Display_in_table
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
DataTable dt;
int i;
int j;
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
try
{
con.Open();
str = "select * from student where sname like '" + TextBox1.Text + "%'";
com = new SqlCommand(str, con);
ds = new DataSet();
sqlda = new SqlDataAdapter(com);
sqlda.Fill(ds, "student");
dt = ds.Tables["student"];
for (i = 0; i <= dt.Rows.Count - 1; i++)
{
TableRow tr = new TableRow();
for (j = 0; j <= dt.Columns.Count - 1; j++)
{
TableCell tc = new TableCell();
tc.Text = dt.Rows[i].ItemArray[j].ToString();
tr.Cells.Add(tc);
Table1.Rows.Add(tr);
}
}
con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
}
Thanks
If this post helps you mark it as answer
Manikavelu VelayuthamPosted Jul 2, 2012, 9:20 AM
1. Dynamically creating the HTML table using the data
http://www.c-sharpcorner.com/uploadfile/farooque84/data-binding-from-dataset-to-html-table-in-net/
2. Using Data Source Object, you can bind the HTML table.
http://www.codeproject.com/Articles/11970/Loading-XML-data-to-HTML-table-using-XML-DSO-objec