Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Changing the binding of a template column

Reply
Thread Tools

Changing the binding of a template column

 
 
Rob Edwards
Guest
Posts: n/a
 
      10-16-2003
I have a datagrid that is bound to different datasources.

The datagrid contains a templated column (dropdown list).

How do I change the selectedvalue binding to the different datasources? I
can do this at design time by changing the datasource of the grid, going
into the databindings popup and adjusted the selected item there... but I
want to be able to do this in code depending on the dataset selected.

Thanks in advance.


 
Reply With Quote
 
 
 
 
Jacob Yang [MSFT]
Guest
Posts: n/a
 
      10-17-2003
Hi Rob,

I have reviewed your issue. Due to the nature of your issue I need to do
additional research to determine the best way to provide assistance. I will
contact you as soon as possible.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ĘC www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
 
 
 
Jacob Yang [MSFT]
Guest
Posts: n/a
 
      10-17-2003
Hi Rob,

If I didn't misunderstand you, you want to change the databinding
properties on the dropdownlist control that is embedded into a Datagrid as
a template column.

If it is the case, we can hook certain event of the datagrid. In such an
event, we can get an reference to the embedded dropdownlist control and do
what we want against the control. For example, here is a sample, which
hooks the ItemCreated event of the datagrid control. In this event, we use
the FindControl method to locate the dropdownlist control and then bind it
to an ArrayList object.

Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated
Dim DropList As DropDownList =
CType(e.Item.Cells(0).FindControl("DropDownList1") , DropDownList)
If (Not DropList Is Nothing) Then
If Not IsPostBack Then
Dim myList As New ArrayList()
myList.Add("Item 1")
myList.Add("Item 2")
myList.Add("Item 3")
myList.Add("Item 4")
myList.Add("Item 5")
DropList.DataSource = myList
DropList.DataBind()
End If
End If
End Sub
End Class

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ĘC www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding multi column values in one column Larry R ASP .Net 1 06-08-2007 06:27 AM
setting Column width of Template Column in Datagrid.. Charleees ASP .Net 2 06-20-2006 12:52 PM
DataGrid loses view state if first column is a template column. Ken Varn ASP .Net 1 08-19-2005 02:54 PM
how to know if a datagrid column is a template column? Dexter ASP .Net 1 01-18-2005 01:45 PM
datagrid template column binding mystery Jim Hammond ASP .Net 0 11-24-2003 10:31 PM



Advertisments