P
PK9
Need help with a DataGrid DropDownList problem. I have a datagrid that
contains several columns, including two ItemTemplate columns that have
DropDownList controls. The DropDownList controls are in columns titled
"Short Title" and "Editions". When a user makes a selection from one of the
"Short Title" dropdown lists in the DataGrid, I need to populate the
"Editions" DropDownList with the necessary editions in the row of the
selected Short Title. This is done by querying the database with the
selected short title.
The problem is that I cannot find a way to identify the necessary edition
dropdown list to populate in the datagrid! I am using an
"OnSelectedIndexChanged" event with the Short Title dropdownlist to retrieve
the selected short title. With this I can successfully query the database
and retrieve the applicable editions. However, I cannot bind these editions
to the correct "Edition" DropdownList in the datagrid because I cannot figure
out how to identify which row had the Short Title DropDownList selected. I
do have a column titled "RowNumber" in my datagrid that would allow me to
find the correct DropDownList in my event handler, but I cannot figure out
how to pass the value along in my event handler.
My current code-set is below:
ASP.NET CODE (datagrid):
__________________________________________
<aspataGrid id="dgKeyRequests" Runat=server>
<Columns>
<asp:BoundColumn DataField="RowNumber" HeaderText="Row #" >
<asp:TemplateColumn HeaderText="Short Title">
<ItemTemplate>
<aspropDownList AutoPostBack=True
OnSelectedIndexChanged="PopulateEditions" Runat="server"
ID="dgKeyRequest_lstShortTitle"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Start Edition">
<ItemTemplate>
<aspropDownList Runat="server" ID="dgKeyRequest_lstEditions" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</DataGrid>
C# CODE BEHIND (OnSelectedIndexChanged event handler):
__________________________________________________
public void PopulateEditions(object sender, System.EventArgs e)
{
//1) Get the ID of the selected short title from the dropdown list in the
datagrid
string strShortTitleID = ((DropDownList)sender).SelectedValue.ToString();
//2) USE THE strShortTitleID variable to retrieve the Editions from the
database
...
//3) Bind Editions to the Edition DropdownList in the same row of the
// selected short title
CANNOT FIGURE OUT THIS STEP!
}
contains several columns, including two ItemTemplate columns that have
DropDownList controls. The DropDownList controls are in columns titled
"Short Title" and "Editions". When a user makes a selection from one of the
"Short Title" dropdown lists in the DataGrid, I need to populate the
"Editions" DropDownList with the necessary editions in the row of the
selected Short Title. This is done by querying the database with the
selected short title.
The problem is that I cannot find a way to identify the necessary edition
dropdown list to populate in the datagrid! I am using an
"OnSelectedIndexChanged" event with the Short Title dropdownlist to retrieve
the selected short title. With this I can successfully query the database
and retrieve the applicable editions. However, I cannot bind these editions
to the correct "Edition" DropdownList in the datagrid because I cannot figure
out how to identify which row had the Short Title DropDownList selected. I
do have a column titled "RowNumber" in my datagrid that would allow me to
find the correct DropDownList in my event handler, but I cannot figure out
how to pass the value along in my event handler.
My current code-set is below:
ASP.NET CODE (datagrid):
__________________________________________
<aspataGrid id="dgKeyRequests" Runat=server>
<Columns>
<asp:BoundColumn DataField="RowNumber" HeaderText="Row #" >
<asp:TemplateColumn HeaderText="Short Title">
<ItemTemplate>
<aspropDownList AutoPostBack=True
OnSelectedIndexChanged="PopulateEditions" Runat="server"
ID="dgKeyRequest_lstShortTitle"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Start Edition">
<ItemTemplate>
<aspropDownList Runat="server" ID="dgKeyRequest_lstEditions" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</DataGrid>
C# CODE BEHIND (OnSelectedIndexChanged event handler):
__________________________________________________
public void PopulateEditions(object sender, System.EventArgs e)
{
//1) Get the ID of the selected short title from the dropdown list in the
datagrid
string strShortTitleID = ((DropDownList)sender).SelectedValue.ToString();
//2) USE THE strShortTitleID variable to retrieve the Editions from the
database
...
//3) Bind Editions to the Edition DropdownList in the same row of the
// selected short title
CANNOT FIGURE OUT THIS STEP!
}