Last post Sep 21, 2011 09:44 PM by Decker Dong - MSFT
Sep 20, 2011 06:17 AM|breath2k|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 06:27 AM|chandrashekar|LINK
Refer the following link in which the user has created a custom grid extending the DataGrid control in asp.net
Sep 21, 2011 09:44 PM|Decker Dong - MSFT|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