Hyper link in Datagrid

  • Thread starter Meheraj shaik via .NET 247
  • Start date
M

Meheraj shaik via .NET 247

hi friends,
I've dynamically created hyperlink and other columns in a grid.iwant to change hyperlink's text property dynamically.i've twotables products & specials.data from product table is diaplayedin grid,if that tables id is existing in specials thenhyperlink's text is editspecial and if it's new then text isnewspecial.when link is clicked it diaplays specials page.
my problem instead of one hyperlink a new hyperlink column iscreated for each row in grid.if 4 rows then 4 hyperlinkcolumns.
I'm giving u code also:
HyperLink edit=new HyperLink();
for(int i=0;i<ds.tables[0].count;i++) //products
{
int prodid=convert.toint32(ds.tables[0].rows["id"].text);
string qry="select specialsid from specials where id=prodid;
sqldataAdapter sda=new sqldataadapter(qry,con);
sqldataAdapter.fill(ds);
if(ds.tables[0].rows.count > 0)
{
edit.text="editspecial";
}
else
{
edit.text="New Special";
}
edit.datanavigateurl="id";
edit.datanavlgateurlformatstring="specials.aspx"?id{0};
dg.addcolumns((Datacolumn)edit);
}
//other columns are created below
dg.databind();
please give me the solution ,thank you


From: Meheraj shaik
 
T

TC

You want to intercept the data is it comes into the datagrid_itemdatabound
event. here you can interrogate the values in the cells (1 row at a time)
and take the appropriate action.

TC


hi friends,
I've dynamically created hyperlink and other columns in a grid.i want to
change hyperlink's text property dynamically.i've two tables products &
specials.data from product table is diaplayed in grid,if that tables id is
existing in specials then hyperlink's text is editspecial and if it's new
then text is newspecial.when link is clicked it diaplays specials page.
my problem instead of one hyperlink a new hyperlink column is created for
each row in grid.if 4 rows then 4 hyperlink columns.
I'm giving u code also:
HyperLink edit=new HyperLink();
for(int i=0;i<ds.tables[0].count;i++) //products
{
int prodid=convert.toint32(ds.tables[0].rows["id"].text);
string qry="select specialsid from specials where id=prodid;
sqldataAdapter sda=new sqldataadapter(qry,con);
sqldataAdapter.fill(ds);
if(ds.tables[0].rows.count > 0)
{
edit.text="editspecial";
}
else
{
edit.text="New Special";
}
edit.datanavigateurl="id";
edit.datanavlgateurlformatstring="specials.aspx"?id{0};
dg.addcolumns((Datacolumn)edit);
}
//other columns are created below
dg.databind();
please give me the solution ,thank you


From: Meheraj shaik
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top