r3nder
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
Here is my Datagrid
any ideas would be very appreciated
// 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();
}
}
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>
any ideas would be very appreciated
http://www.c-sharpcorner.com/UploadFile/mahesh/DataBindingInDataGridMCB112022005002207AM/DataBindingInDataGridMCB1.aspx
ASKER
This is for asp.Net with C# code behind
No links please
No links please
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent job - It was a please learning from you :)
ASKER
Pleasure**