Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 22, 2011 01:44 AM by Decker Dong - MSFT
Sep 20, 2011 10:17 AM|LINK
I haven't created my own control before but it's got to the point where I think I need to, I need to be able to create a datagrid where I can add different controls to the fields and creating template columns dynamically isn't quite cutting it, what is the
best way to start looking into this?
Sep 20, 2011 10:27 AM|LINK
Refer the following link in which the user has created a custom grid extending the DataGrid control in asp.net
Sep 22, 2011 01:44 AM|LINK
If you want to add several (I mean "limited" controls). You don't need to extend it but just handle ItemDataBound or some other events to do this:
More info at:
http://msdn.microsoft.com/en-us/library/aa479316.aspx, here's the sample from there:
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
If e.Item.ItemType = ListItemType.EditItem Then
Dim DRV As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim CurrentShip As String = DRV("ShipVia")
Dim DDL As DropDownList = _
Dim SQL As String = _
"SELECT ShipperID, CompanyName FROM Shippers ORDER BY ShipperID"
Dim DA As SqlDataAdapter = New SqlDataAdapter(SQL, ConnStr)
Dim DS As New DataSet
Dim item As ListItem
DDL.DataSource = DS.Tables("Shippers").DefaultView
DDL.DataTextField = "CompanyName"
DDL.DataValueField = "ShipperID"
item = DDL.Items.FindByValue(CurrentShip)
If Not item Is Nothing Then item.Selected = True