Link to home
Start Free TrialLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

Binding data to datagrid in C# web form

I am trying to bind the data from a stored proceedure to a datagrid here is the code to retrieve the data
// Retrieving data from Stored Proceedure and bind it to datagrid
           try
           {
               con.Open();
               SqlCommand com = new SqlCommand("spx_leadershipAnalysis", con);
               com.CommandType = CommandType.StoredProcedure;
               rdr = com.ExecuteReader();
               while (rdr.Read())
               {
                   //Response.Write(rdr["Name"]);
                   
               } 

               //Response.Write(rdr);
               con.Close();
           }
           catch (Exception ex)
           {
               Response.Write(ex.Message);
               con.Close();
           }

        }

Open in new window


Here is my Datagrid
 <div id="div-datagrid">

    <asp:DataGrid id="DataGrid1" runat="server" CssClass="Grid" UseAccessibleHeader="True">
    <AlternatingItemStyle CssClass="GridAltRow"></AlternatingItemStyle>
    <ItemStyle CssClass="GridRow"></ItemStyle>
    <Columns>
    <asp:BoundColumn DataField="Uname" HeaderText="Name" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="entered" HeaderText="Entered" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlIntegrity" HeaderText="Integrity" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlValuePeople" HeaderText="Value People" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlTeamwork" HeaderText="Teamwork" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlAccountability" HeaderText="Accountability" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlCommunication" HeaderText="Communication" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlVision" HeaderText="Vision" 
        ItemStyle-Wrap="False"></asp:BoundColumn>   
    <asp:BoundColumn DataField="ddlAdaptability" HeaderText="Adaptability" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlHumility" HeaderText="Humility" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlCreativity" HeaderText="Creativity" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlTeachability" HeaderText="Teachability" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlPositiveInfluence" HeaderText="Positive Influence" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    <asp:BoundColumn DataField="ddlCourage" HeaderText="Courage" 
        ItemStyle-Wrap="False"></asp:BoundColumn>
    </Columns>
</asp:DataGrid>
    </div>

Open in new window


any ideas would be very appreciated
Avatar of plusone3055
plusone3055
Flag of United States of America image

Avatar of r3nder

ASKER

This is for asp.Net with C# code behind
No links please
ASKER CERTIFIED SOLUTION
Avatar of JessyEzzy
JessyEzzy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of r3nder

ASKER

Excellent job - It was a please learning from you :)
Avatar of r3nder

ASKER

Pleasure**