Click here to Skip to main content
13,095,218 members (76,821 online)
Rate this:
 
Please Sign up or sign in to 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 16-Sep-12 22:14pm
Updated 16-Sep-12 23:22pm
v2
Comments
darshith 17-Sep-12 4:16am
   
could u elobrate your question
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
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi ,
Check this
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];
}


<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
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

I'm know about it little information and this code is here

so please try it
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];
}
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100