data bind of datagrid with dataset
-
Rock Star. wrote:
datafield="'Column name"
Why there is a single quotation(') near Column name
**$**herin Iranimose
-
Its a typing mistake there is no single quote in the code. Do u know why there is no data in my data grid.
Rock Star
Use a datatable instead of dataset. and try the GV is displaying or not.
**$**herin Iranimose
-
Use a datatable instead of dataset. and try the GV is displaying or not.
**$**herin Iranimose
-
can you please do a copy paste of the gridview HTML code and the vb code. So that I can simulate the same thing and find out the problem.
**$**herin Iranimose
-
hi I tried ProductDG.DataSource = m_DataSet.Tables[0] in my code but same result. I cant see my datasrid control. But when I am trying to put the condition for m_DataSet.DefaultViewManager <> Nothing it is going in the else part and showing nothing for defaultviemanager.
Rock Star
Hi, why are you using m_DataSet.DefaultViewManager anyhow? I always use things like...
Dataset ds = GetDataset();
Gridview.Datasource = ds.Tables[0]; // Even with a .CreateDataReader if you want to
GridView.Databind();And works perfectly fine. I assume the GridView is visible on the aspx marking right? (Sorry for this obvious question, but you never know...)
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
-
can you please do a copy paste of the gridview HTML code and the vb code. So that I can simulate the same thing and find out the problem.
**$**herin Iranimose
This is the aspx code u asked for <asp:GridView ID="ProductDG" runat="server" AutoGenerateColumns=false AllowPaging="true" PageSize=10 Height="182px" Width="155px"> <Columns> <asp:BoundField DataField="column Name" HeaderText="Name" SortExpression="column Name" > <HeaderStyle Font-Names="Arial" Font-Size="12px" /> <ItemStyle Font-Names="Arial" Font-Size="12px" /> </asp:BoundField> </Columns> </asp:GridView> and this is the vb code for the databinding Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Productds As New DataSet Dim m_DataAdapter As New SqlClient.SqlDataAdapter( _ "query", "connectionstring") Dim m_DataSet As New DataSet ' Fill the DataSet. m_DataAdapter.Fill(m_DataSet, "Demo") ' Bind the DataGrid to the DataSet's first DataTable. ProductDG.DataSource = m_DataSet.DefaultViewManager ProductDG.DataMember = "Demo" End sub
Rock Star
-
This is the aspx code u asked for <asp:GridView ID="ProductDG" runat="server" AutoGenerateColumns=false AllowPaging="true" PageSize=10 Height="182px" Width="155px"> <Columns> <asp:BoundField DataField="column Name" HeaderText="Name" SortExpression="column Name" > <HeaderStyle Font-Names="Arial" Font-Size="12px" /> <ItemStyle Font-Names="Arial" Font-Size="12px" /> </asp:BoundField> </Columns> </asp:GridView> and this is the vb code for the databinding Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Productds As New DataSet Dim m_DataAdapter As New SqlClient.SqlDataAdapter( _ "query", "connectionstring") Dim m_DataSet As New DataSet ' Fill the DataSet. m_DataAdapter.Fill(m_DataSet, "Demo") ' Bind the DataGrid to the DataSet's first DataTable. ProductDG.DataSource = m_DataSet.DefaultViewManager ProductDG.DataMember = "Demo" End sub
Rock Star
Rock Star. wrote:ProductDG.DataSource = m_DataSet.DefaultViewManager ProductDG.DataMember = "Demo" Dear You set Datasource but you need to bind Datagrid after that ProductDG.DataBind() Also If someone tells you to post code then post your complete code. Here you used "column name" but you should post with column field name which you want to bind Now dont tell that you did mistake here to post code regard kHan please don't forget to vote on the post that helped you.
-
This is the aspx code u asked for <asp:GridView ID="ProductDG" runat="server" AutoGenerateColumns=false AllowPaging="true" PageSize=10 Height="182px" Width="155px"> <Columns> <asp:BoundField DataField="column Name" HeaderText="Name" SortExpression="column Name" > <HeaderStyle Font-Names="Arial" Font-Size="12px" /> <ItemStyle Font-Names="Arial" Font-Size="12px" /> </asp:BoundField> </Columns> </asp:GridView> and this is the vb code for the databinding Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Productds As New DataSet Dim m_DataAdapter As New SqlClient.SqlDataAdapter( _ "query", "connectionstring") Dim m_DataSet As New DataSet ' Fill the DataSet. m_DataAdapter.Fill(m_DataSet, "Demo") ' Bind the DataGrid to the DataSet's first DataTable. ProductDG.DataSource = m_DataSet.DefaultViewManager ProductDG.DataMember = "Demo" End sub
Rock Star
Try this, It is working for me.
Dim Productds As New DataSet Dim m_DataAdapter As New SqlClient.SqlDataAdapter( _ "query", "connectionstring") Dim m_DataSet As New DataSet ' Fill the DataSet. m_DataAdapter.Fill(m_DataSet) ' Bind the DataGrid to the DataSet's first DataTable. ProductDG.DataSource = m_DataSet ProductDG.DataBind();
**$**herin Iranimose
-
This is the aspx code u asked for <asp:GridView ID="ProductDG" runat="server" AutoGenerateColumns=false AllowPaging="true" PageSize=10 Height="182px" Width="155px"> <Columns> <asp:BoundField DataField="column Name" HeaderText="Name" SortExpression="column Name" > <HeaderStyle Font-Names="Arial" Font-Size="12px" /> <ItemStyle Font-Names="Arial" Font-Size="12px" /> </asp:BoundField> </Columns> </asp:GridView> and this is the vb code for the databinding Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Productds As New DataSet Dim m_DataAdapter As New SqlClient.SqlDataAdapter( _ "query", "connectionstring") Dim m_DataSet As New DataSet ' Fill the DataSet. m_DataAdapter.Fill(m_DataSet, "Demo") ' Bind the DataGrid to the DataSet's first DataTable. ProductDG.DataSource = m_DataSet.DefaultViewManager ProductDG.DataMember = "Demo" End sub
Rock Star
The problem with you code is 1.
Rock Star. wrote:
m_DataSet.DefaultViewManager
You can directly use m_DataSet or one table inside the dadta set 2. Like Pathan told You are not binding the grid view. using
ProductDG.DataBind()
So when i told you to use datatable you used it but you didnot bind it to GV. I think now you got the problem.**$**herin Iranimose
-
The problem with you code is 1.
Rock Star. wrote:
m_DataSet.DefaultViewManager
You can directly use m_DataSet or one table inside the dadta set 2. Like Pathan told You are not binding the grid view. using
ProductDG.DataBind()
So when i told you to use datatable you used it but you didnot bind it to GV. I think now you got the problem.**$**herin Iranimose