Up vote 0 down vote favorite 1 share g+ share fb share tw.
Here I did every thing from codebehind. I created a gridview dynamically. DataTable dt=null; dt = loadDynamicGrid(columnname, ds); GridView grdnew = new GridView(); grdnew.
DataSource = dt; grdnew.DataBind(); private DataTable loadDynamicGrid(string column,DataSet ds) { #region Code for preparing the DataTable DataTable dt = new DataTable(); //Create an ID column for adding to the Datatable DataColumn dcol ;//= new DataColumn(ID1, typeof(System. Int32)); ButtonColumn btncolm; HyperLinkColumn hplink; for (int I = 0; I =null) { if (columni == "BUY" || columni == "Buy" || columni == "BuyNow" || columni == "Details" || columni == "ViewDetails" || columni == "BuyQty" || columni == "Purchase") { //btncolm = new ButtonColumn(); //btncolm. HeaderText = columni; //btncolm.
Text = columni; //dt.Columns. Add(btncolm. Text); hplink = new HyperLinkColumn(); hplink.
HeaderImageUrl = "http://www.google.com"; hplink. HeaderText = columni; hplink. Text = columni; dt.Columns.
Add(hplink. Text); } else { dcol = new DataColumn(columni, typeof(System. String)); dt.Columns.
Add(dcol); } } } int k=0; foreach (DataRow dr in ds. Tables0. Rows) { DataRow myrow = dt.NewRow(); for (int j = 0; j = null) { string sdfsd = Convert.
ToString(drcolumnj); if (columnj == "BUY" || columnj == "Buy" || columnj == "BuyNow" || columnj == "Details" || columnj == "ViewDetails" || columnj == "BuyQty" || columnj == "Purchase") { //myrowcolumnj = "http://www.google. Com1/"; myrowcolumnj = drcolumnj; } else { if (Convert. ToString(drcolumnj).TrimEnd() == " ") { myrowcolumnj = ""; } else { myrowcolumnj = drcolumnj; } } if (columnj == "Stock" || columnj == "QtyInStock" || columnj == "Qty" || columnj == "Available" || columnj.ToLower() == "onhand" || columnj == "QuantityOnHand" || columnj == "QtyAvailable" || columnj == "InStock" || columnj == "Avail" || columnj == "Inventory" || columnj == "Quantity" || columnj == "Availability") { if (Convert.
ToString(drcolumnj)! = "0" && Convert. ToString(drcolumnj)!
= "" && drcolumnj! = null && Convert. ToString(drcolumnj).TrimEnd()!
=" ") { stock = drcolumnj.ToString(); } } } } k++; dt.Rows. Add(myrow); } #endregion column = null; return dt; } Then I adding to a div everytime like: mydiv.Controls. Add(grdnew); as above I repeate the loop for different table of data to bind to gridview.
Here I need a link button to gridview. So I added a hyperlink column to datatable,but i'm not getting any linkbutton in grid. I have more than 20 tables of data to bind to grid.
So I preferred to create the grid dynamically. Asp.net gridview datatable linkbutton link|improve this question edited Jan 19 at 5:39 asked Jan 17 at 7:05tiru829 57% accept rate.
TableCell tc1 = new TableCell(); tc1. Wrap=true; this. LnkRecvGpNo=new LinkButton(); lnkRecvGpNo.
Text="RecvGp No"; this.lnkRecvGpNo. Click+=new EventHandler(lnkRecvGpNo_Click); tc1.Controls. Add(lnkRecvGpNo).
This is for your table if you want to generate the linkbutton in table and if you wish to dynamically add link in grid view create a templatefield & generate linkbutton in that. – Neha Jan 17 at 10:45 can you tell me,where to write this code. – tiru Jan 17 at 11:06 if you are creating new template field for grid put that code in databound of gridview and if using above do where you add columns to table – Neha Jan 17 at 11:17 as I shown my above code,i didn't create any template field for the grid i'm directly assigning the datatable to the grid datasource,so how to add a linkbutton?
– tiru Jan 17 at 12:46.
Just replace the grid with datagrid and add hyperlinkcolumn to datatable and give data to that column as click me DataTable dt=new DataTable(); HyperLinkColumn hplink = new HyperLinkColumn(); hplink. Text = column1i; dt.Columns. Add(hplink.
Text); DataRow myrow = dt.NewRow(); myrowcolumn1l = String. Format("" + drcolumnj + ""); dt.Rows. Add(myrow); DataGrid1.
DataSource=dt; DataGrid1.DataBinding(); Thats it problem solved.
Just replace the grid with datagrid and add hyperlinkcolumn to datatable and give data to that column as click me.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.