E
Elton Wang
Hi Wanky,
Following is solution. I'm sure it works.
' Add both textbox and checkbox in datagrid
<asp:TemplateColumn HeaderText="Choice">
<ItemTemplate>
<asp:CheckBox ID="ckChoice"
Runat="server"></asp:CheckBox>
<asp:TextBox ID="txtChoice"
Runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
' in ItemDataBound set one of control invisible according
to type
Dim drv As DataRowView = e.Item.DataItem
If drv(FieldTypeIndex).ToString.Equals("Textbox") Then
e.Item.FindControl("ckChoice").Visible = False
Else
e.Item.FindControl("txtChoice").Visible = False
End If
' in save button Click retrieve control type depending on
type filed
For Each item As DataGridItem In Me.dgdSearch.Items
If item.Cells(FieldTypeIndex).Text.Equals("Textbox")
Then
Dim txtCtrl As TextBox = CType(item.FindControl
("txtChoice"), TextBox)
' process
Else
Dim ck As CheckBox = CType(item.FindControl
("ckChoice"), CheckBox)
' process
End If
Next
If you still have problem, please let me know.
HTH
Elton Wang
Following is solution. I'm sure it works.
' Add both textbox and checkbox in datagrid
<asp:TemplateColumn HeaderText="Choice">
<ItemTemplate>
<asp:CheckBox ID="ckChoice"
Runat="server"></asp:CheckBox>
<asp:TextBox ID="txtChoice"
Runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
' in ItemDataBound set one of control invisible according
to type
Dim drv As DataRowView = e.Item.DataItem
If drv(FieldTypeIndex).ToString.Equals("Textbox") Then
e.Item.FindControl("ckChoice").Visible = False
Else
e.Item.FindControl("txtChoice").Visible = False
End If
' in save button Click retrieve control type depending on
type filed
For Each item As DataGridItem In Me.dgdSearch.Items
If item.Cells(FieldTypeIndex).Text.Equals("Textbox")
Then
Dim txtCtrl As TextBox = CType(item.FindControl
("txtChoice"), TextBox)
' process
Else
Dim ck As CheckBox = CType(item.FindControl
("ckChoice"), CheckBox)
' process
End If
Next
If you still have problem, please let me know.
HTH
Elton Wang