infinitizon
MIS
Hi all, I'm working on with a gridview and I want to add a radiobutton to each row. The value of radiobutton on each row should be the code from database.
Currently, in my aspx I have
and my aspx.vb
This works perfect. However I need to be able to pass different queries with different codes then I tried this
and
and it fails.
So I'm thinking of putting the TemplateField dynamically, any ideas?
____________________
Men put up a strong face just to cover their weaknesses...good!
But a smile makes them live longer....
Which would you choose?
Think about it.
Currently, in my aspx I have
Code:
<asp:GridView ID="GridView1" runat="server" >
<Columns>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<input name="codeTitleName" type="radio" value='<%# Eval("loc_code") %>' onclick="doJavascript()" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
fillStatesControls("Select [loc_code], [loc_descr] From " & Request.QueryString("q"), "code")
Me.DataBind()
End Sub
Protected Sub fillStatesControls(ByRef theQuery As String)
Dim myda As SqlDataAdapter
Dim ds As DataSet
Dim mycn As New SqlConnection(connectionString)
myda = New SqlDataAdapter(theQuery, mycn)
ds = New DataSet
myda.Fill(ds, "theTables")
Dim ds_source As DataSet = ds 'Previously Retrieved Dataset
Dim code As New BoundField
code.HeaderText = "code"
code.DataField = "loc_code"
GridView1.Columns.Add(code)
Dim desc As New BoundField
desc.HeaderText = "Description"
desc.DataField = "loc_descr"
GridView1.Columns.Add(desc)
GridView1.Visible = True
GridView1.DataSource = ds_source
End Sub
Code:
<asp:GridView ID="GridView1" runat="server" >
<Columns>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<input name="codeTitleName" type="radio" value='<%# Eval(codeTitle) %>' onclick="doJavascript()" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
fillStatesControls("Select [loc_code], [loc_descr] From " & Request.QueryString("q"), "code", "Description", "loc_code", "loc_descr")
Me.DataBind()
End Sub
Protected Sub fillStatesControls(ByRef theQuery As String, ByVal codeTitle As String, ByVal descTitle As String, _
ByVal codeDataField As String, ByVal descDataField As String)
Dim myda As SqlDataAdapter
Dim ds As DataSet
Dim mycn As New SqlConnection(connectionString)
myda = New SqlDataAdapter(theQuery, mycn)
ds = New DataSet
myda.Fill(ds, "theTables")
Dim ds_source As DataSet = ds 'Previously Retrieved Dataset
Dim radio as
Dim code As New BoundField
code.HeaderText = codeTitle
code.DataField = codeDataField
GridView1.Columns.Add(code)
Dim desc As New BoundField
desc.HeaderText = descTitle
desc.DataField = descDataField
GridView1.Columns.Add(desc)
GridView1.Visible = True
GridView1.DataSource = ds_source
End Sub
So I'm thinking of putting the TemplateField dynamically, any ideas?
____________________
Men put up a strong face just to cover their weaknesses...good!
But a smile makes them live longer....
Which would you choose?
Think about it.