Click here to Skip to main content
15,895,805 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in a asp.net page, i have 1 drop down list and another is gridview.
In gridview, there is a link button which used for navigation to another page using QueryString.
Now Suppose i want to send DropDown value in postbackUrl of Linkbutton, how can we do that without codebehind.

Ex:


XML
<asp:DropDownList ID="ddlVl" runat="server"  
            </asp:DropDownList>


XML
<asp:GridView ID="gvdetails" runat="server" AutoGenerateColumns="false" DataKeyNames="" EmptyDataText="Data Not Present" HeaderStyle-BackColor="Green" HeaderStyle-Font-Bold="true" HeaderStyle-ForeColor="White"  ShowHeader="true" ShowHeaderWhenEmpty="true" Width="100%"  >
                               <RowStyle HorizontalAlign="Center" />
                               <AlternatingRowStyle HorizontalAlign="Center" />
                               <Columns>


XML
<asp:TemplateField HeaderText="Remain">
                                       <ItemTemplate>
                                           <asp:LinkButton ID="lnk" runat="server" OnClientClick="window.document.forms[0].target='_blank';" PostBackUrl='<%# "~/abc.aspx?ddlvalue="  %></asp:LinkButton>

                                       </ItemTemplate>
                                   </asp:TemplateField>










I want to send ddlVl value to abc page via PostbackURl.
Posted

1 solution

SQL
onclientclick call a script function to get dropdown selected value and use
window.location = '/pagename.aspx?value=' + ddlvalue;
 
Share this answer
 
Comments
arpit jodawat 2-Apr-14 8:07am    
thx for reply, one question.

can we directly attach the drop down value to url without any script like:
PostBackUrl='<%# "~/abc.aspx?ddlvalue="+ddlV1.selectedvalue.text %>.
i tried this but it is not working.

i am asking this because in case if there might be more than one link button and in some link button you want to send dropdown value and in some case you don't want to,
if i go via script then i need to put if else condition.

So if there is a direct way then i can directly handle that thing in postbackurl.
Charan_Kumar 2-Apr-14 8:24am    
how can you attach the value to url without getting dropdown selected value?
Charan_Kumar 2-Apr-14 8:30am    
OnClientClick="return Navigate()"

<script type="text/javascript">
function Navigate() {
var ddlVal= document.getElementById('dropdownID').value;
window.location = '/pagename.aspx?value=' + ddlVal;
}
</script>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900