Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,
I am creating a gridview for customer and their introducer.I have created a grid view and populated it with the database values.But i need the introducer name in my grid view along with their no.But i have a seperate column for intoducer id only.I have to get the name of introducer by their member ID.I don'T know how to populate that column .Kindly help me.

And my code is

Member_status.aspx

XML
<asp:GridView ID="bussgrid" runat="server" AutoGenerateColumns="False"
                     BorderColor="Aqua" Width="520px" Height="143px" >
                       <Columns>
                           <asp:BoundField DataField="Member_Name" HeaderText="Name" HeaderStyle-BorderColor="Aqua" HeaderStyle-Font-Names="verdana" HeaderStyle-Font-Size="7" HeaderStyle-ForeColor="Purple"
                               SortExpression="Member_Name" />
                           <asp:BoundField DataField="CombinedId" HeaderText="MemberID" ReadOnly="True" HeaderStyle-BorderColor="Aqua" HeaderStyle-Font-Names="verdana" HeaderStyle-Font-Size="7" HeaderStyle-ForeColor="Purple"
                               SortExpression="CombinedId" />
                           <asp:BoundField DataField="IntroducerID" HeaderText="IntroducerID"  HeaderStyle-BorderColor="Aqua" HeaderStyle-Font-Names="verdana" HeaderStyle-Font-Size="7" HeaderStyle-ForeColor="Purple"
                               SortExpression="IntoducerID" />
                           <asp:BoundField DataField="Placement_Side" HeaderText="Position" HeaderStyle-BorderColor="Aqua" HeaderStyle-Font-Names="verdana" HeaderStyle-Font-Size="7" HeaderStyle-ForeColor="Purple"
                               SortExpression="Placement_Side" />
                           <asp:TemplateField HeaderText="Introducer Name">
                         <ItemTemplate>
                            <asp:Label ID="Intro_Name" runat="server"></asp:Label>
                            <%--<asp:Literal ID="Intro_Name" runat="server" />--%>
                    </ItemTemplate>
                    </asp:TemplateField>
                       </Columns>
                       </asp:GridView>


member_status.aspx.cs


protected void Button1_Click(object sender, EventArgs e)
    {
        string text = "select Member_Name,CombinedId,Gender,Member_DOB,[Placement_Side],[City],[Join_Date],IntroducerID,SponsorID from Member_registration where IntroducerID='" + TextBox1.Text + "' ";
        string text1 = text + " select Member_Name from Member_Registration where CombinedID='"+ TextBox1.Text +"'";
        SqlCommand cmd = new SqlCommand(text1, connection);
        connection.Open();
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        sda.Fill(dt);
        bussgrid.DataSource = dt;
        bussgrid.DataBind();
        
       
    }
    protected void bussgrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            


        }
Posted
Updated 31-Jan-14 23:55pm
v2
Comments
Do you have a separate table for Introducer?
rama dinakaran 1-Feb-14 4:13am    
No i have only one table [Member_registration]

you can refer below link for more idea on this

display-rows-in-multiple-columns-in-asp-net-gridview[^]
 
Share this answer
 
Comments
rama dinakaran 1-Feb-14 4:22am    
how can i use a listview inside a gridview??? i'm sorry i don't get the idea how to use that.Can you help me with any examples
[no name] 1-Feb-14 4:56am    
http://stackoverflow.com/questions/10058443/how-to-show-a-listview-inside-a-gridview-controls-item-template

you can see this..
yout can use this query

select IntoducerID+' '+Member_Name as no_name,Placement_Side from abc_table

and after bind your gridview
 
Share this answer
 
you have to bind the data to show in the gridview.you can bind one field to one column of the grid view.so in the select query you have to select the same field twice.
 
Share this answer
 

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