469,602 Members | 1,829 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Gridview with hyper link

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

May 5 '07 #1
1 1794
On May 5, 11:16 am, yogarajan.gane...@gmail.com wrote:
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>

May 5 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by CSharpguy | last post: by
reply views Thread by jobo | last post: by
3 posts views Thread by peerraghu | last post: by
9 posts views Thread by rosoft | last post: by
1 post views Thread by Kalaram | last post: by
1 post views Thread by Author | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.