Gridview with hyper link

  • Thread starter yogarajan.ganesan
  • Start date
Y

yogarajan.ganesan

hello friend
am new in asp.net
i have one doubt pls help me

page load:

DataSet ds = BuildDataSet();
DataGrid1.DataSource = ds;
DataGrid1.DataBind();


private DataSet BuildDataSet()
{
DataSet ret = new DataSet();
DataTable dt = new DataTable();
DataRow dr = null;

// Define table column names and datatypes
DataColumn dc = new DataColumn("ID",Type.GetType("System.Int32"));
dt.Columns.Add(dc);
dc = new DataColumn("Name",Type.GetType("System.String"));
dt.Columns.Add(dc);
dc = new DataColumn("Date",Type.GetType("System.DateTime"));
dt.Columns.Add(dc);

// Fill the table with sample data
for(int i = 1;i < = 10;i++)
{
dr = dt.NewRow();
dr["ID"] = i;
dr["Name"] = "John Smith";
dr["Date"] = DateTime.Now.AddSeconds(i * 10);
dt.Rows.Add(dr);
}

// Return the dataset to the caller
ret.Tables.Add(dt);

return ret;
}
current output

ID Name date
1 johnsmith
..
....

i need one more link colum

how can i add

i want out put looks like this

ID Name Date link
1 john smith 1/1/2007 hyperlink (link go to my another page b.aspx)

pls help me it is very urgent
 
G

Guest

hello friend
am new in asp.net
i have one doubt pls help me

page load:

DataSet ds = BuildDataSet();
DataGrid1.DataSource = ds;
DataGrid1.DataBind();

private DataSet BuildDataSet()
{
DataSet ret = new DataSet();
DataTable dt = new DataTable();
DataRow dr = null;

// Define table column names and datatypes
DataColumn dc = new DataColumn("ID",Type.GetType("System.Int32"));
dt.Columns.Add(dc);
dc = new DataColumn("Name",Type.GetType("System.String"));
dt.Columns.Add(dc);
dc = new DataColumn("Date",Type.GetType("System.DateTime"));
dt.Columns.Add(dc);

// Fill the table with sample data
for(int i = 1;i < = 10;i++)
{
dr = dt.NewRow();
dr["ID"] = i;
dr["Name"] = "John Smith";
dr["Date"] = DateTime.Now.AddSeconds(i * 10);
dt.Rows.Add(dr);

}

// Return the dataset to the caller
ret.Tables.Add(dt);

return ret;}

current output

ID Name date
1 johnsmith
.
...

i need one more link colum

how can i add

i want out put looks like this

ID Name Date link
1 john smith 1/1/2007 hyperlink (link go to my another page b.aspx)

pls help me it is very urgent

<asp:GridView ... AutoGenerateColumns="false" runat="server">
<Columns>
<asp:BoundField DataField="ID" />
<asp:BoundField DataField="Name" />
<asp:BoundField DataField="Date" DataFormatString="{0:MM/dd/yyyy}"
HtmlEncode="false" />
<asp:TemplateField>
<ItemTemplate>
<a href="b.aspx">link</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top