GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  ADO.NET 2.0
Go To First  |  Previous Question  |  Next Question 
 ADO.NET 2.0  |  Question 6 of 19    Print  
how can we add a check box or a dropdown list to a column in a datagrid?
post your answer



  
Total Answers and Comments: 11 Last Update: December 17, 2008     Asked by: ratnakar 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
September 17, 2005 11:42:56   #1  
vinod arya        

RE: how can we add a check box or a dropdown list to a...
you can use vaspread a 3rd party tool
 
Is this answer useful? Yes | No
September 20, 2005 05:54:24   #2  
Shobha Member Since: September 2005   Contribution: 6    

RE: how can we add a check box or a dropdown list to a...

By using template column as

<asp:TemplateColumn>

<asp:ItemTemplate>

<asp:CheckBox></asp:CheckBox>

<asp:DropDownList></asp:DropDownList>

</asp:ItemTemplate>

</asp:TemplateColumn>


 
Is this answer useful? Yes | No
September 21, 2005 09:55:19   #3  
Mahendra Raja        

RE: how can we add a check box or a dropdown list to a...
If u want to add a check box in a Datagrid in Asp.Net applications. U select the datagrid in the webform and at bottom of properties window u r able to view property builder (Click it) then a dialog window will be opened. there u select columns and then in the column box select template column. the type a name for that column. click apply then close that window. now (right click) the datagrid and select edit template there select the column name displayed bcoz it will display only the template column. then entire datagrid appearance will be changed. Now in the datagrid click the item template using mouse. the cursor blibks in that column. Go to the tool box double click any one of the control like(Check-Box). now it will be added to the item template. then right click the datagrid and (click) End Template Editing.now u will be getting the grid to original appearance with Checkbox in the template column.
 
Is this answer useful? Yes | No
September 26, 2005 00:33:16   #4  
Nithin        

RE: how can we add a check box or a dropdown list to a...
Add a template column to the datagrid and select the Checkbox or DropdownList for the ItemTemplate
 
Is this answer useful? Yes | No
September 29, 2005 06:04:08   #5  
Rameez Mohammed        

RE: how can we add a check box or a dropdown list to a...
just make the column where u want to put the combo box a Template Column.Then right click the grid go to--> edit template-->column name.Delete the text box in the field.place the drop down there.in code(VB)get the control as ctype(datagridname.findcontrol( ddl1 ) dropdownlist).text.trim to get the value of the ddl.
 
Is this answer useful? Yes | No
October 10, 2005 08:56:25   #6  
Saira        

RE: how can we add a check box or a dropdown list to a...
By making use of a template column for the datagrid and then droping a checkbox or dropdownlist on it.Finally binding it with the datasource.
 
Is this answer useful? Yes | No
October 14, 2005 01:47:51   #7  
Ketan        

RE: how can we add a check box or a dropdown list to a...

Hello dr.

With the help of template command coloumn we can add all types of webserver control in datagrid.

Thanks

With regards

Ketan Pathak


 
Is this answer useful? Yes | No
November 02, 2005 18:10:49   #8  
entm Member Since: November 2005   Contribution: 1    

RE: how can we add a check box or a dropdown list to a...

Here's a programatic example:


<asp:TemplateColumn HeaderText myColumn ItemStyle-Wrap False >
<ItemTemplate>
<asp:DropDownList ID dropList1 Runat server DataTextField myText DataValueField table_identifier DataSource '< # GetSrc() >' SelectedIndex '< # GetSelIndex(Container.DataItem( myColumn )) >' Enabled '< # GetBool( myColumn ) >' OnSelectedIndexChanged GetSelChanged AutoPostBack True/>
</ItemTemplate>


Define this at the top of your code:

Dim ds As DataSet New DataSet

Function GetSrc() As DataSet

cnstr ConfigurationSettings.AppSettings( myDBConnString )

dropList1.Clear()

Dim cn As New SqlConnection(cnstr)

sql SELECT table_identifier mytext FROM myTable


Dim
da As SqlDataAdapter

da New SqlDataAdapter(sql cn)

' fill dataset
cn.Open()
da.Fill(ds myTable )
cn.Close()

' Add null row to dataset.
Dim dt As DataTable ds.Tables( myTable )

Dim NullRow As DataRow dt.NewRow()
NullRow( table_identifier ) 0
NullRow( myText ) Select Something Here
dt.Rows.InsertAt(NullRow 0)

Return ds

End Function

Function GetSelIndex(ByVal iVal As Object) As Integer

' loop through dataset

Dim sVal As String iVal.ToString
Dim iLoop As Integer
Dim dt As DataTable
dt ds.Tables( myTable )

For iLoop 0 To dt.Rows.Count - 1

If sVal dt.Rows(iLoop)( table_identifier ).ToString Then

Return iLoop

End If

Next iLoop

End Function

Function GetBool()
' This function would contain code allowing you to disable the control if the user/entity did not have proper rights to use this control in the grid or change it.

End Function


 
Is this answer useful? Yes | No
April 13, 2006 15:18:15   #9  
Leigh Anne        

RE: how can we add a check box or a dropdown list to a...

Ok I think Eric Moore's post may have been what I'm looking for but I'm a total novice and need help understanding the code. I have added a template column to my data grid to hold a column of checkboxes. I cannot figure out though how to use the click event procedure to make the system recognize when the boxes are checked. Basically I have a data grid representing the courses a college student is currently enrolled in. There is a column called Drop which is my template column that holds checkboxes. I want to allow the student to check mark the box(es) and hit a submit button. Then I want the info from those boxes emailed to a particular person. My main problem right now is getting the code to recognize when the box is checked. Could someone help me in very basic terms?? :) Thanks so much!


 
Is this answer useful? Yes | No
October 03, 2007 10:23:37   #10  
lohanigeit Member Since: June 2006   Contribution: 2    

RE: how can we add a check box or a dropdown list to a...
Add the checkbox or drop down in ur itemtemplate column & access it through it's ID.
 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape