Click here to Skip to main content
16,004,587 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi frnds,
i have a listbox and dropdownlist control inside the gridview control. I load the lstbox and dropdown. There's a problem in getting the values of dropdown and listbox selected values. I tried many codes but its not getting the appropriate selected values. It always gets me the first value.
XML
<asp:GridView ID="user_grid" runat="server" AllowPaging="True" PageSize="10"
        AutoGenerateColumns="False"
        onpageindexchanging="user_grid_PageIndexChanging"
          DataKeyNames="adminfilepath" onrowupdating="user_grid_RowUpdating"
        onrowdatabound="user_grid_RowDataBound">

     <asp:TemplateField HeaderText="SL No.">

      <%# Container.DataItemIndex + 1%>


 <asp:TemplateField Visible="false">

 <asp:Label ID="lblid" runat="server" Text='<%# Bind("Content_id") %>'>


 <asp:TemplateField HeaderText="ManuscriptNo">

 <asp:LabeL ID="lblmanuno" runat="server" Text='<%# Bind("ManuscriptNo") %>'>


  <asp:TemplateField HeaderText="UserName">

  <asp:Label ID="lbluser" runat="server" Text='<%# Bind("UserName") %>'>


 <asp:TemplateField HeaderText="DateOfSubmission">

 <asp:Label ID="lblDoS" runat="server" Text='<%# Bind("DateofSubmission") %>'>


 <asp:TemplateField HeaderText="ArticleName">

 <asp:Label ID="lbl_article" runat="server" Text='<%# Bind("Articlename") %>'>


 <asp:TemplateField HeaderText="ArticleType">

 <asp:Label ID="lbl_articletype" runat="server" Text='<%# Bind("Articletype") %>'>


 <asp:TemplateField HeaderText="FileDownload">

 <asp:LinkButton ID="lnkDownload" runat="server" CommandName="Download" OnClick="lnkDownload_Click">Download


 <asp:TemplateField Visible="false">

 <asp:Label ID="lbl_Reviewerfilepath" runat="server" Text='<%# Bind("reviewerfilepath") %>'>


 <asp:TemplateField HeaderText="ReviwerList">

 <asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple"  EnableViewState="False"   AppendDataBoundItems="true" >



 <asp:TemplateField HeaderText="Status">

 <asp:DropDownList ID="drp_status" runat="server">
 <asp:ListItem Text="Select Status" Value="">
 <asp:ListItem Text="Accept" Value="1" >
 <asp:ListItem Text="Reject" Value="2" >



 <asp:TemplateField HeaderText="Update">

 <asp:LinkButton ID="lnkupadte" runat="server" CommandName="Update">Update

Plz help !!!!
Posted
v3
Comments
Please post your codes.
echosound 17-Aug-12 6:57am    
<asp:GridView ID="user_grid" runat="server" AllowPaging="True" PageSize="10"
AutoGenerateColumns="False"
onpageindexchanging="user_grid_PageIndexChanging"
DataKeyNames="adminfilepath" onrowupdating="user_grid_RowUpdating"
onrowdatabound="user_grid_RowDataBound">
<columns>
<asp:TemplateField HeaderText="SL No.">
<itemtemplate>
<%# Container.DataItemIndex + 1%>


<asp:TemplateField Visible="false">
<itemtemplate>
<asp:Label ID="lblid" runat="server" Text='<%# Bind("Content_id") %>'>


<asp:TemplateField HeaderText="ManuscriptNo">
<itemtemplate>
<asp:LabeL ID="lblmanuno" runat="server" Text='<%# Bind("ManuscriptNo") %>'>


<asp:TemplateField HeaderText="UserName">
<itemtemplate>
<asp:Label ID="lbluser" runat="server" Text='<%# Bind("UserName") %>'>


<asp:TemplateField HeaderText="DateOfSubmission">
<itemtemplate>
<asp:Label ID="lblDoS" runat="server" Text='<%# Bind("DateofSubmission") %>'>


<asp:TemplateField HeaderText="ArticleName">
<itemtemplate>
<asp:Label ID="lbl_article" runat="server" Text='<%# Bind("Articlename") %>'>


<asp:TemplateField HeaderText="ArticleType">
<itemtemplate>
<asp:Label ID="lbl_articletype" runat="server" Text='<%# Bind("Articletype") %>'>


<asp:TemplateField HeaderText="FileDownload">
<itemtemplate>
<asp:LinkButton ID="lnkDownload" runat="server" CommandName="Download" OnClick="lnkDownload_Click">Download


<asp:TemplateField Visible="false">
<itemtemplate>
<asp:Label ID="lbl_Reviewerfilepath" runat="server" Text='<%# Bind("reviewerfilepath") %>'>


<asp:TemplateField HeaderText="ReviwerList">
<itemtemplate>
<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple" EnableViewState="False" AppendDataBoundItems="true" >



<asp:TemplateField HeaderText="Status">
<itemtemplate>
<asp:DropDownList ID="drp_status" runat="server">
<asp:ListItem Text="Select Status" Value="">
<asp:ListItem Text="Accept" Value="1" >
<asp:ListItem Text="Reject" Value="2" >



<asp:TemplateField HeaderText="Update">
<itemtemplate>
<asp:LinkButton ID="lnkupadte" runat="server" CommandName="Update">Update



echosound 17-Aug-12 7:04am    
i have also loaded my listbox ctrl from Db in the grid_RowDataBound event now ,How to get the selected values of the lst box

This search will give you thousands of search results, see here[^]
 
Share this answer
 
Comments
echosound 17-Aug-12 7:09am    
i have also loaded my listbox ctrl from Db in the grid_RowDataBound event now ,How to get the selected values of the lst box
echosound 17-Aug-12 7:10am    
this is my Source Code ...


<asp:GridView ID="user_grid" runat="server" AllowPaging="True" PageSize="10"
AutoGenerateColumns="False"
onpageindexchanging="user_grid_PageIndexChanging"
DataKeyNames="adminfilepath" onrowupdating="user_grid_RowUpdating"
onrowdatabound="user_grid_RowDataBound">
<columns> <asp:TemplateField HeaderText="SL No.">
<itemtemplate>
<%# Container.DataItemIndex + 1%>


<asp:TemplateField Visible="false">
<itemtemplate>
<asp:Label ID="lblid" runat="server" Text='<%# Bind("Content_id") %>'>


<asp:TemplateField HeaderText="ManuscriptNo">
<itemtemplate>
<asp:LabeL ID="lblmanuno" runat="server" Text='<%# Bind("ManuscriptNo") %>'>


<asp:TemplateField HeaderText="UserName">
<itemtemplate>
<asp:Label ID="lbluser" runat="server" Text='<%# Bind("UserName") %>'>


<asp:TemplateField HeaderText="DateOfSubmission">
<itemtemplate>
<asp:Label ID="lblDoS" runat="server" Text='<%# Bind("DateofSubmission") %>'>


<asp:TemplateField HeaderText="ArticleName">
<itemtemplate>
<asp:Label ID="lbl_article" runat="server" Text='<%# Bind("Articlename") %>'>


<asp:TemplateField HeaderText="ArticleType">
<itemtemplate>
<asp:Label ID="lbl_articletype" runat="server" Text='<%# Bind("Articletype") %>'>


<asp:TemplateField HeaderText="FileDownload">
<itemtemplate>
<asp:LinkButton ID="lnkDownload" runat="server" CommandName="Download" OnClick="lnkDownload_Click">Download


<asp:TemplateField Visible="false">
<itemtemplate>
<asp:Label ID="lbl_Reviewerfilepath" runat="server" Text='<%# Bind("reviewerfilepath") %>'>


<asp:TemplateField HeaderText="ReviwerList">
<itemtemplate>
<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple" EnableViewState="False" AppendDataBoundItems="true" >



<asp:TemplateField HeaderText="Status">
<itemtemplate>
<asp:DropDownList ID="drp_status" runat="server">
<asp:ListItem Text="Select Status" Value="">
<asp:ListItem Text="Accept" Value="1" >
<asp:ListItem Text="Reject" Value="2" >



<asp:TemplateField HeaderText="Update">
<itemtemplate>
<asp:LinkButton ID="lnkupadte" runat="server" CommandName="Update">Update


Manas Bhardwaj 17-Aug-12 8:21am    
5ed. I am seeing this as trend on CP that they post the question without any tries/efforts.
echosound 17-Aug-12 8:24am    
hey man i tried a lot if u have any suggestion just send me k
 
Share this answer
 
Comments
echosound 17-Aug-12 7:09am    
i have also loaded my listbox ctrl from Db in the grid_RowDataBound event now ,How to get the selected values of the lst box
echosound 17-Aug-12 7:10am    
this is my Source Code ...


<asp:GridView ID="user_grid" runat="server" AllowPaging="True" PageSize="10"
AutoGenerateColumns="False"
onpageindexchanging="user_grid_PageIndexChanging"
DataKeyNames="adminfilepath" onrowupdating="user_grid_RowUpdating"
onrowdatabound="user_grid_RowDataBound">
<columns> <asp:TemplateField HeaderText="SL No.">
<itemtemplate>
<%# Container.DataItemIndex + 1%>


<asp:TemplateField Visible="false">
<itemtemplate>
<asp:Label ID="lblid" runat="server" Text='<%# Bind("Content_id") %>'>


<asp:TemplateField HeaderText="ManuscriptNo">
<itemtemplate>
<asp:LabeL ID="lblmanuno" runat="server" Text='<%# Bind("ManuscriptNo") %>'>


<asp:TemplateField HeaderText="UserName">
<itemtemplate>
<asp:Label ID="lbluser" runat="server" Text='<%# Bind("UserName") %>'>


<asp:TemplateField HeaderText="DateOfSubmission">
<itemtemplate>
<asp:Label ID="lblDoS" runat="server" Text='<%# Bind("DateofSubmission") %>'>


<asp:TemplateField HeaderText="ArticleName">
<itemtemplate>
<asp:Label ID="lbl_article" runat="server" Text='<%# Bind("Articlename") %>'>


<asp:TemplateField HeaderText="ArticleType">
<itemtemplate>
<asp:Label ID="lbl_articletype" runat="server" Text='<%# Bind("Articletype") %>'>


<asp:TemplateField HeaderText="FileDownload">
<itemtemplate>
<asp:LinkButton ID="lnkDownload" runat="server" CommandName="Download" OnClick="lnkDownload_Click">Download


<asp:TemplateField Visible="false">
<itemtemplate>
<asp:Label ID="lbl_Reviewerfilepath" runat="server" Text='<%# Bind("reviewerfilepath") %>'>


<asp:TemplateField HeaderText="ReviwerList">
<itemtemplate>
<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple" EnableViewState="False" AppendDataBoundItems="true" >



<asp:TemplateField HeaderText="Status">
<itemtemplate>
<asp:DropDownList ID="drp_status" runat="server">
<asp:ListItem Text="Select Status" Value="">
<asp:ListItem Text="Accept" Value="1" >
<asp:ListItem Text="Reject" Value="2" >



<asp:TemplateField HeaderText="Update">
<itemtemplate>
<asp:LinkButton ID="lnkupadte" runat="server" CommandName="Update">Update


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