Anda di halaman 1dari 1

try

{
table1.rows.clear();
string qry = "select mycalendar from newcalendar";
sqldataadapter da = new sqldataadapter(qry,con);
dataset ds = new dataset();
da.fill(ds);
foreach(datarow dr in ds.tables[0].rows)
{
tablecell tc= new tablecell();
tablecell tc1 = new tablecell();
tablerow tr = new tablerow();

system.web.ui.webcontrols.imagebutton imgbtn = new imagebutton();


imgbtn.imageurl="images/directory1.gif";
imgbtn.click +=new imageclickeventhandler(imgbtn_click);
imgbtn.id="img"+i.tostring();
imgbtn.tooltip=dr["directoryid"].tostring();

linkbutton lkbtn = new linkbutton();


lkbtn.text=dr["directoryname"].tostring();
lkbtn.click +=new eventhandler(lkbtn_click);
lkbtn.id=dr["directoryid"].tostring();

tc.controls.add(imgbtn);
tc1.controls.add(lkbtn);
tr.cells.add(tc);
tr.cells.add(tc1);
table1.rows.add(tr);
i++;
}
}
catch(exception ex)
{
response.write(ex.message);
}
**********************************************************************************

private void imgbtn_click(object sender, imageclickeventargs e)


{
imagebutton imgbtn;
imgbtn=(imagebutton)sender;
session["tbl1"]=imgbtn.tooltip;
response.redirect("some.aspx");
}

private void lkbtn_click(object sender, eventargs e)


{
linkbutton lnkbtn;
lnkbtn=(linkbutton)sender;
session["tbl1"]=lnkbtn.id.tostring();
response.redirect("some.aspx");
}