M
m3ckon
Hi there,
please help if you can, I'm having an issue with droponnlists in a
datagrid
I have a datagrid which is populated from a query .. all works fine
I've added two extra columns, one is a dropdownlist and the other is a
button which runs the command selectcode for this:
<Columns>
<asp:BoundColumn DataField="Salutation"
HeaderText="Salutation"></asp:BoundColumn>
<asp:BoundColumn DataField="FirstName" HeaderText="First
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="LastName" HeaderText="Last
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="Post Code" SortExpression="Post Code"
HeaderText="Post Code"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Users">
<ItemTemplate>
<aspropDownList id=DDlUsers runat="server" DataSource="<%#
Itemtypes %>" >
</aspropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Select" ButtonType="PushButton"
CommandName="Select"></asp:ButtonColumn>
</Columns>
The datagrid renders correctly and when I click the button I've written
code to find the id of the dropdownlist on the same row as the button
which has been clicked ... however I can't access the dropdownlist value
and I NEED to do this in order to continue with my project.
My code is listed below:
Private Sub LeadsDG_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles LeadsDG.SelectedIndexChanged
Dim ddstr As String
ddstr = LeadsDG.SelectedItem.Cells(4).Controls(0).ClientID
ddstr = Replace(ddstr, "__ctl1", "_DDlUsers")
End Sub
Please someone tell me how to access the drop down, I've tried this
(with writing the vlue to a text box):
Dim DDlist1 As DropDownList = CType(LeadsDG.FindControl(ddstr),
DropDownList)
TextBox1.Text = DDlist1.SelectedItem.Value
But I get the following error when I click a value:
Object reference not set to an instance of an object.
Please help me access the dropdownlist values, I know that the sub is
being run and that the id is the correct control, but I'm stuck getting
it working
Regrds,
m3ckon
please help if you can, I'm having an issue with droponnlists in a
datagrid
I have a datagrid which is populated from a query .. all works fine
I've added two extra columns, one is a dropdownlist and the other is a
button which runs the command selectcode for this:
<Columns>
<asp:BoundColumn DataField="Salutation"
HeaderText="Salutation"></asp:BoundColumn>
<asp:BoundColumn DataField="FirstName" HeaderText="First
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="LastName" HeaderText="Last
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="Post Code" SortExpression="Post Code"
HeaderText="Post Code"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Users">
<ItemTemplate>
<aspropDownList id=DDlUsers runat="server" DataSource="<%#
Itemtypes %>" >
</aspropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Select" ButtonType="PushButton"
CommandName="Select"></asp:ButtonColumn>
</Columns>
The datagrid renders correctly and when I click the button I've written
code to find the id of the dropdownlist on the same row as the button
which has been clicked ... however I can't access the dropdownlist value
and I NEED to do this in order to continue with my project.
My code is listed below:
Private Sub LeadsDG_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles LeadsDG.SelectedIndexChanged
Dim ddstr As String
ddstr = LeadsDG.SelectedItem.Cells(4).Controls(0).ClientID
ddstr = Replace(ddstr, "__ctl1", "_DDlUsers")
End Sub
Please someone tell me how to access the drop down, I've tried this
(with writing the vlue to a text box):
Dim DDlist1 As DropDownList = CType(LeadsDG.FindControl(ddstr),
DropDownList)
TextBox1.Text = DDlist1.SelectedItem.Value
But I get the following error when I click a value:
Object reference not set to an instance of an object.
Please help me access the dropdownlist values, I know that the sub is
being run and that the id is the correct control, but I'm stuck getting
it working
Regrds,
m3ckon