Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 14, 2012 02:24 PM by mr_jay_bee
Jun 12, 2012 05:33 PM|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 06:24 PM|LINK
Why is it necessary to NOT use a template column? This is what they are ment for.
Jun 13, 2012 05:36 PM|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 08:02 AM|LINK
Seems you have solved the issue. If so, please share the solution with us.
Jun 14, 2012 01:26 PM|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 02:15 PM|LINK
Why do you need to build the grid dynamically?
Jun 14, 2012 02:21 PM|LINK
Jun 14, 2012 02:24 PM|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