Last post Jun 14, 2012 10:24 AM by mr_jay_bee
Jun 12, 2012 01:33 PM|mr_jay_bee|LINK
I have a rather large gridview (70+ columns) that I'm creating dynamically based on query results. Without using a template column, I would like to create a check box for each row of data so that a user may select one or multiple rows of data. Is that
possible without using the template column?
If possible...can anyone share any links and/or code (VB please)
Jun 12, 2012 02:24 PM|jbenson001|LINK
Why is it necessary to NOT use a template column? This is what they are ment for.
Jun 13, 2012 01:36 PM|mr_jay_bee|LINK
I've tried using the template column, but I'm still getting funky results. Currently, I'm creating the grid on the fly:
For Each dc In MyDataConnections.m_DAL.DataSet.Tables("table_of_Main_Data").Columns
Dim bfield As New BoundField
bfield.DataField = dc.ColumnName
bfield.HeaderText = dc.ColumnName
grdTableDetails.DataSource = MyDataConnections.m_DAL.DataSet.Tables("table_of_Main_Data")
This code works and I bind my data....my grid shows up.....I see a spot for the checkbox (eg...an additional column at pos(1), but there is no checkbox in said column?
I've tried running the additional code after the bind:
Dim tccheckcell As New TableCell
Dim checkbox = New CheckBox
which makes the checkbox show up, but it offsets all of my data to the right (eg...headers stay in the same position, but the row data moves over one space)
Jun 14, 2012 04:02 AM|Qin Dian Tang - MSFT|LINK
Seems you have solved the issue. If so, please share the solution with us.
Jun 14, 2012 09:26 AM|shreenidhi|LINK
I ve done this without using template column in aspx page.
But somehow u have to use codebeind to dynamically check box/dropdowns uinsg .cs file have a look
void ITemplate.InstantiateIn(Control container)
DropDownList cmd = new DropDownList();
//cmd.AutoPostBack = true;
cmd.ID = "cmd";
//cmd.SelectedItem.Value = "HI";
cmd.Items.Insert(2, "Week OFF");
cmd.SelectedIndexChanged += new EventHandler(Dynamic_Method);
protected void Dynamic_Method(object sender, EventArgs e)
value = (DropDownList)sender).SelectedItem.Value;//u can use checkbox as well
TemplateField TmpCol = new TemplateField();
TmpCol.HeaderText = dls[i].ToString();
TmpCol.ItemTemplate = new TemplateHandler();
You can use the checkbox to achive the same.. Its bit tedious and time consuming but still u can achive. You would not find so many blogs answering this as this requirement is complex and needs observation by techy
Jun 14, 2012 10:15 AM|jbenson001|LINK
Why do you need to build the grid dynamically?
Jun 14, 2012 10:21 AM|mr_jay_bee|LINK
Jun 14, 2012 10:24 AM|mr_jay_bee|LINK
I have multiple datatables feeding the one grid.......some tables return more columns/rows than the other (depends on what the user is looking for).....didn't want to get tied down creating boundfields dynamically or creating template based grids. Plus
with a variety of columns/rows its easier to format them when done dynamically