Hello,
I have a datagrid with only one row and its having 2 dropdownlists, I need
to populate the secodn dropdownlist on the basis of the selection in the
first dropdown. but I am not able to populate the second dropdown, as its not
bale to find the specified control, even though the dropdownlist with the
specified name exists in the datagrid.
my .aspx page code goes like this
<asp:DataGrid id="Datagrid2" runat="server" Cssclass="txtTen" Width="600px"
Height="35px" Font-Size="9px" Font-Names="Verdana"
AutoGenerateColumns="False" Visible="True" BackColor="#FCFBEB"
BorderColor="#FFC0C0">
<HeaderStyle Font-Size="9px" Font-Names="Verdana"
Font-Bold="True"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Hotel Type">
<ItemTemplate>
<asp:DropDownList id="ddlhtype" runat="server" Font-Size="9px"
Font-Names="Verdana" Width="100px" AutoPostBack="true" >
<asp:ListItem Value="Hotel Type">Hotel Type</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Hotel name">
<ItemTemplate>
<asp:DropDownList id="ddlhname" runat="server" Font-Size="9px"
Font-Names="Verdana" Width="100px"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</asp:DataGrid>
my code behind for the grid goes like this
Private Sub Datagrid2_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles Datagrid2.ItemCreated
If Not e.Item.FindControl("ddlhtype") Is Nothing Then
AddHandler CType(e.Item.FindControl("ddlhtype"),
DropDownList).SelectedIndexChanged, AddressOf GetHotelNames
End If
End Sub
the handler definition goes like this
Public Sub GetHotelNames(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim quotemgr As New QuotationManager
Dim objcitystop As New CitystopServicesBE
objcitystop.ServiceCode = "CITYSTOP"
objcitystop.detailcode = "HTNM"
If Not CType(Datagrid2.FindControl("ddlhtype"), DropDownList) Is
Nothing Then
Dim strname As String
strname = CType(sender, DropDownList).SelectedValue.ToString()
objcitystop.Filter = strname
Dim col As New Collection
If Not CType(e.Item.FindControl("ddlhtype"),
DropDownList) Is Nothing Then
col = quotemgr.getcitystopdetails(objcitystop)
Dim objcity As CitystopServicesBE
For Each objcity In col
Dim strcode As New ListItem
strcode.Text = objcity.desc
strcode.Value = objcity.serviceid
Response.Write("before ddlname <br>")
If Not CType(Datagrid2.FindControl("ddlhname"),
DropDownList) Is Nothing Then
CType(Datagrid2.FindControl("ddlhname"),
DropDownList).Items.Add(strcode)
End If
Next
End If
Catch ex As Exception
Response.Write(ex.ToString)
End Try
but I am surprised to find that , it doesnt find both the mentioned
dropdowns, Can you pls tell me where I am going wrong.
Your expert advise would be highly appreciated.
Rgds
Shiju 2 2369
Shiju,
Once you are in your GetHotelNames method you can get a reference to either
dropdownlist like so:
dim htype as DropDownList = ctype(sender, DropDownList)
dim hValue as DropDownList = ctype(ctype(htype.Parent.Parent,
DataGridITem).FindControl("ddlHValue"), DropdownList)
Those that help?
Karl
"Shiju Poyilil" <Sh**********@discussions.microsoft.com> wrote in message
news:F1**********************************@microsof t.com... Hello,
I have a datagrid with only one row and its having 2 dropdownlists, I need to populate the secodn dropdownlist on the basis of the selection in the first dropdown. but I am not able to populate the second dropdown, as its
not bale to find the specified control, even though the dropdownlist with the specified name exists in the datagrid.
my .aspx page code goes like this
<asp:DataGrid id="Datagrid2" runat="server" Cssclass="txtTen"
Width="600px" Height="35px" Font-Size="9px" Font-Names="Verdana" AutoGenerateColumns="False" Visible="True" BackColor="#FCFBEB" BorderColor="#FFC0C0">
<HeaderStyle Font-Size="9px" Font-Names="Verdana" Font-Bold="True"></HeaderStyle>
<Columns> <asp:TemplateColumn HeaderText="Hotel Type"> <ItemTemplate> <asp:DropDownList id="ddlhtype" runat="server" Font-Size="9px" Font-Names="Verdana" Width="100px" AutoPostBack="true" > <asp:ListItem Value="Hotel Type">Hotel Type</asp:ListItem> </asp:DropDownList> </ItemTemplate> </asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Hotel name"> <ItemTemplate> <asp:DropDownList id="ddlhname" runat="server" Font-Size="9px" Font-Names="Verdana" Width="100px"></asp:DropDownList> </ItemTemplate> </asp:TemplateColumn> </asp:DataGrid>
my code behind for the grid goes like this Private Sub Datagrid2_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
Datagrid2.ItemCreated If Not e.Item.FindControl("ddlhtype") Is Nothing Then AddHandler CType(e.Item.FindControl("ddlhtype"), DropDownList).SelectedIndexChanged, AddressOf GetHotelNames End If
End Sub
the handler definition goes like this
Public Sub GetHotelNames(ByVal sender As Object, ByVal e As EventArgs) Try Dim quotemgr As New QuotationManager Dim objcitystop As New CitystopServicesBE objcitystop.ServiceCode = "CITYSTOP" objcitystop.detailcode = "HTNM"
If Not CType(Datagrid2.FindControl("ddlhtype"), DropDownList) Is Nothing Then Dim strname As String strname = CType(sender, DropDownList).SelectedValue.ToString() objcitystop.Filter = strname
Dim col As New Collection If Not CType(e.Item.FindControl("ddlhtype"), DropDownList) Is Nothing Then
col = quotemgr.getcitystopdetails(objcitystop) Dim objcity As CitystopServicesBE For Each objcity In col Dim strcode As New ListItem strcode.Text = objcity.desc strcode.Value = objcity.serviceid Response.Write("before ddlname <br>")
If Not CType(Datagrid2.FindControl("ddlhname"), DropDownList) Is Nothing Then
CType(Datagrid2.FindControl("ddlhname"), DropDownList).Items.Add(strcode) End If Next End If Catch ex As Exception Response.Write(ex.ToString) End Try
but I am surprised to find that , it doesnt find both the mentioned dropdowns, Can you pls tell me where I am going wrong.
Your expert advise would be highly appreciated.
Rgds Shiju
Thanks Karl , It really worked for me.
Rgds
Shiju
"Karl" wrote: Shiju, Once you are in your GetHotelNames method you can get a reference to either dropdownlist like so:
dim htype as DropDownList = ctype(sender, DropDownList) dim hValue as DropDownList = ctype(ctype(htype.Parent.Parent, DataGridITem).FindControl("ddlHValue"), DropdownList)
Those that help?
Karl "Shiju Poyilil" <Sh**********@discussions.microsoft.com> wrote in message news:F1**********************************@microsof t.com... Hello,
I have a datagrid with only one row and its having 2 dropdownlists, I need to populate the secodn dropdownlist on the basis of the selection in the first dropdown. but I am not able to populate the second dropdown, as its not bale to find the specified control, even though the dropdownlist with the specified name exists in the datagrid.
my .aspx page code goes like this
<asp:DataGrid id="Datagrid2" runat="server" Cssclass="txtTen" Width="600px" Height="35px" Font-Size="9px" Font-Names="Verdana" AutoGenerateColumns="False" Visible="True" BackColor="#FCFBEB" BorderColor="#FFC0C0">
<HeaderStyle Font-Size="9px" Font-Names="Verdana" Font-Bold="True"></HeaderStyle>
<Columns> <asp:TemplateColumn HeaderText="Hotel Type"> <ItemTemplate> <asp:DropDownList id="ddlhtype" runat="server" Font-Size="9px" Font-Names="Verdana" Width="100px" AutoPostBack="true" > <asp:ListItem Value="Hotel Type">Hotel Type</asp:ListItem> </asp:DropDownList> </ItemTemplate> </asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Hotel name"> <ItemTemplate> <asp:DropDownList id="ddlhname" runat="server" Font-Size="9px" Font-Names="Verdana" Width="100px"></asp:DropDownList> </ItemTemplate> </asp:TemplateColumn> </asp:DataGrid>
my code behind for the grid goes like this Private Sub Datagrid2_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles Datagrid2.ItemCreated If Not e.Item.FindControl("ddlhtype") Is Nothing Then AddHandler CType(e.Item.FindControl("ddlhtype"), DropDownList).SelectedIndexChanged, AddressOf GetHotelNames End If
End Sub
the handler definition goes like this
Public Sub GetHotelNames(ByVal sender As Object, ByVal e As EventArgs) Try Dim quotemgr As New QuotationManager Dim objcitystop As New CitystopServicesBE objcitystop.ServiceCode = "CITYSTOP" objcitystop.detailcode = "HTNM"
If Not CType(Datagrid2.FindControl("ddlhtype"), DropDownList) Is Nothing Then Dim strname As String strname = CType(sender, DropDownList).SelectedValue.ToString() objcitystop.Filter = strname
Dim col As New Collection If Not CType(e.Item.FindControl("ddlhtype"), DropDownList) Is Nothing Then
col = quotemgr.getcitystopdetails(objcitystop) Dim objcity As CitystopServicesBE For Each objcity In col Dim strcode As New ListItem strcode.Text = objcity.desc strcode.Value = objcity.serviceid Response.Write("before ddlname <br>")
If Not CType(Datagrid2.FindControl("ddlhname"), DropDownList) Is Nothing Then
CType(Datagrid2.FindControl("ddlhname"), DropDownList).Items.Add(strcode) End If Next End If Catch ex As Exception Response.Write(ex.ToString) End Try
but I am surprised to find that , it doesnt find both the mentioned dropdowns, Can you pls tell me where I am going wrong.
Your expert advise would be highly appreciated.
Rgds Shiju
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stanley J Mroczek |
last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ?
<Columns>
<asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True"
HeaderText="Option...
|
by: Dominic |
last post by:
Hi guys,
I'm not sure if this question belongs to FAQ, but I couldn't find a
concrete answer.
I created a Datagrid control using ItemTemplate, but it's NOT a
in-place editing datagrid. One of...
|
by: Shane O. Pinnell |
last post by:
I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated!
I have a datagrid populated from a dataset. I have a...
|
by: m3ckon |
last post by:
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...
|
by: Tim::.. |
last post by:
Can someone please tell me how I go about preselecting an item in a drop
drown list when I click the Edit Command in a datagrid?
I have tried the following but it doesn't work for me!
I would...
|
by: Daniel Doyle |
last post by:
Hello and apologies in advance for the amount of code in this post. I've
also sent this message to the Sharepoint group, but thought that ASP.NET
developers may also be able to help, even though...
|
by: Mark Waser |
last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a
datagrid.
In the page PreRender step, the selected index of the datagrid is
successfully set during databinding. Yet,...
|
by: glenn |
last post by:
Hi folks,
I have a DropDownList in a DataGrid that is populated from records in a
database.
I want to add a value that might be a string such as "Select a Company" for
the first item since an...
|
by: joethika |
last post by:
i have a problem in asp.net.i don't know how to add dependent dropdownlist within the datagrid in asp.net using c# code.that is one dropdownlist is dependent on another within the datagrid.pls help...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |