Ask Dr. Dotnetsky - DropDownList in Header of GridView control....
Asked By Ghaffar Abdul on 04-Dec-06 11:41 PM
Hi Sir...
Well I am facing a difficulty in sending the selected value as query string from the Dropdwonlist(in Header of GridView Control) and GridView control's one of column through the HyperLinkButton of GridView Control to another page. I not able to send the second or third selected value from the dropdownlist to another page, although the first selected value can be. Actually there is the problem of posting back. Please try to understand the whole scenario..
This is the code I am working on
***********************************
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="SchoolCode"
DataSourceID="AccessDataSource1">
<Columns>
<asp:BoundField DataField="SchoolCode" HeaderText="SchoolCode" ReadOnly="True" SortExpression="SchoolCode" />
<asp:BoundField DataField="SchoolName" HeaderText="SchoolName" SortExpression="SchoolName" />
<asp:BoundField DataField="VillageName" HeaderText="VillageName" SortExpression="VillageName" />
<asp:TemplateField>
<HeaderTemplate>
Select Year:
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem>2006</asp:ListItem>
<asp:ListItem>2005</asp:ListItem>
</asp:DropDownList>
</HeaderTemplate>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("SchoolCode", "Default2.aspx?SchoolCode={0}&Year="+((DropDownList)(this.GridView1.HeaderRow.FindControl("DropDownList1"))).SelectedValue.ToString()) %>'
Text='<%# Eval("SchoolCode", "Get Details") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
********************************
Thanks in advance for your precious replies....
Abdul Ghaffar
yep that happen coz
K Pravin Kumar Reddy replied to Ghaffar Abdul on 05-Dec-06 09:17 AM
yep that happen coz when page loads it will pass the initiall dropdown select value only if u want to assign new value in hyperling u have to update that hyperling querystring parameter value right for that u can do one thing in dropdown selected index change event u change that hyperling url by passing newly seleted value..