SqlDataSource -connection problem
while i do the web application, i tried to display those details in gridview. when i configure SqlDataSource it shows an error like object reference not set to an instance of an object. anyone can help me?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ravikumar GPosted May 29, 2013, 1:02 AM
Sunny SharmaPosted May 22, 2013, 4:55 AM
Hope this helps!!
Sandeep Singh ShekhawatPosted May 22, 2013, 3:23 AM
SqlDataSource Design Code
<asp:SqlDataSource ID="EmployeeDataSource" runat="server"
ConnectionString="Data Source=sandeepss-PC; database=development; user=sa;password=knowdev"
SelectCommand="select Id, Name, Emp_Code,Emp_Age from EMPLOYEE">
asp:SqlDataSource>
GridView Design
DataSourceID property set by SqlDataSource ID to bind grid view.
<asp:GridView ID="gvCustomres" runat="server"
DataSourceID="EmployeeDataSource"
AutoGenerateColumns="False"
GridLines="None"
AllowPaging="true"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt"
Width=40%>
<Columns>
<asp:TemplateField HeaderText="S.No." ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<%#Container.DataItemIndex+1%>
ItemTemplate>
asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Employee Name" />
<asp:BoundField DataField="Emp_Code" HeaderText="Employee Code" />
<asp:BoundField DataField="Emp_Age" HeaderText="Employee Age" />
Columns>
asp:GridView>
Sunny SharmaPosted May 22, 2013, 2:29 AM