Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to insert two month name in Gridview in asp.net like Jan-march in on Lable


suppose there are two dropdown list from one dropdownlist i select jan and second dropdown list select march, then theses two value insert into Gridview One lable (gridview label name is "month") like jan -march
Posted
Updated 16-Sep-12 23:22pm
v2
Comments
darshith 17-Sep-12 4:16am    
could u elobrate your question
FIROZ KHANIT 17-Sep-12 5:23am    
suppose there are two dropdown list from one dropdownlist i select jan and second dropdown list select march, then theses two value insert into Gridview One lable (gridview label name is "month") like jan -march
Vani Kulkarni 17-Sep-12 4:26am    
Please elaborate your question.
FIROZ KHANIT 17-Sep-12 5:23am    
suppose there are two dropdown list from one dropdownlist i select jan and second dropdown list select march, then theses two value insert into Gridview One lable (gridview label name is "month") like jan -march

Hi ,
Check this
C#
protected void Button1_Click(object sender, EventArgs e)
{
    List<string> test = new List<string>();
    test.Add(DropDownList1.SelectedValue + " ,  " + DropDownList2.SelectedValue);
   GridView1.DataSource = test;
    GridView1.DataBind();
    ((Label)GridView1.Rows[0].Cells[0].FindControl("Label2")).Text = test[0];
}


XML
<div>
       <asp:DropDownList ID="DropDownList1" runat="server">
           <asp:ListItem>January</asp:ListItem>
           <asp:ListItem>February</asp:ListItem>
           <asp:ListItem>March</asp:ListItem>
           <asp:ListItem>April</asp:ListItem>
       </asp:DropDownList>
       <asp:DropDownList ID="DropDownList2" runat="server">
           <asp:ListItem>January</asp:ListItem>
           <asp:ListItem>February</asp:ListItem>
           <asp:ListItem>march</asp:ListItem>
           <asp:ListItem>april</asp:ListItem>
       </asp:DropDownList>
   </div>
   <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
   <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
       <Columns>
           <asp:TemplateField>
               <ItemTemplate>
                   <asp:Label ID="Label2" runat="server" ></asp:Label>
               </ItemTemplate>
           </asp:TemplateField>
       </Columns>
   </asp:GridView>


Best Regards
M.Mitwalli
 
Share this answer
 
v2
I'm know about it little information and this code is here

so please try it
C#
protected void Button1_Click(object sender, EventArgs e)
{
    List<string> test = new List<string>();
    test.Add(DropDownList1.SelectedValue + " ,  " + DropDownList2.SelectedValue);
   GridView1.DataSource = test;
    GridView1.DataBind();
    ((Label)GridView1.Rows[0].Cells[0].FindControl("Label2")).Text = test[0];
}
 
Share this answer
 
v2

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