|
Rock Star. wrote: I put this code in it but still I cant see my datagrid.
First check your query.It returns any dataset.Run that query in Sql Query Analyzer.
regard
kHan
please don't forget to vote on the post that helped you.
|
|
|
|
|
Hi,
I checked my query its perfect. I checked dataset.tables(0).rows.count and its returning number of rows in the dataset. I dont everywhere same code is given to bind the datagrid to dataset. I dont know why it is not working in my case.
Rock Star
|
|
|
|
|
ProductDG.DataSource = m_DataSet.DefaultViewManager
Is there any reason to use DefaultViewManager.
You can also do in this way.
ProductDG.DataSource = m_DataSet.Tables[0]
or
If m_DataSet.DefaultViewManager <> Nothing Then
//bind DataGrid
Else
//Is null
End If
Regard
Khan
please don't forget to vote on the post that helped you.
|
|
|
|
|
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];
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."
|
|
|
|
|
Try like,
' Bind the DataGrid to the DataSet's first DataTable.
ProductDG.DataSource = m_DataSet.Tables("Demo")
ProductDG.DataBind()
Tell me one thing... Does your DataGrid has columns bounded? Could you please post your *.aspx HTML?
|
|
|
|
|
Yes my datagrid has one bounded column in .aspx file but wen i run the page I am getting an error for "A field or property with the name 'Column name' was not found on the selected data source." but my table has the column I have specified in bond column section of datagrid.
This is the aspx code for datagrid
<asp:gridview id="ProductDG" runat="server" autogeneratecolumns="false" allowpaging="true" pagesize="10" height="182px" width="155px" > <columns>
<asp:boundfield datafield="'Column name" headertext="Name"><br>
</asp:boundfield>
</columns>
</asp:gridview>
Rock Star
|
|
|
|
|
Rock Star. wrote: datafield="'Column name"
Why there is a single quotation(') near Column name
|
|
|
|
|
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.
|
|
|
|
|
I tried data table too but same result.
Rock Star
|
|
|
|
|
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.
|
|
|
|
|
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.
<asp:boundfield datafield="column Name" headertext="Name" sortexpression="column Name" ></asp:boundfield>
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.
|
|
|
|
|
Try this, It is working for me.
<br />
Dim Productds As New DataSet<br />
<br />
Dim m_DataAdapter As New SqlClient.SqlDataAdapter( _<br />
"query", "connectionstring")<br />
<br />
Dim m_DataSet As New DataSet<br />
' Fill the DataSet.<br />
m_DataAdapter.Fill(m_DataSet)<br />
<br />
' Bind the DataGrid to the DataSet's first DataTable.<br />
ProductDG.DataSource = m_DataSet<br />
ProductDG.DataBind();
|
|
|
|
|
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.
|
|
|
|
|
Thanx a lot guys its working now.
Rock Star
|
|
|
|
|
how brwose network directory?
|
|
|
|
|
You mean you want to programmatically browse a network drive?
Or you want to map a network drive thru your program?
|
|
|
|
|
when i do browse network shared folder through coding. then open dialog box they ask me username and password. but i dont' like this, (may be this due to anti virus install in both the pc) i have user name and password. now but i want to create exe in C#.net that fix user name and password and connect network pc.
|
|
|
|
|
Can you please post some code that you are using?
|
|
|
|
|
string path = @"\\192.168.1.16\Docoments";
if (System.IO.Directory.Exists(path))
{
}
else
{
}
|
|
|
|
|
Are you using the open file dialog to select and open files?
What is the code within the IF?
|
|
|
|
|
I have a requirement in ASP.Net, where is there is a HTML page which will be around 1200 pages with records fetched from a Database using some reports. The records shown in HTML is in a Listed View some thing like
Name : BS
Age : 66
Work : Personal : xyz
: Buisines : xyz
Name : AA
Age : 66
Work : Offial : abc
: Buisines : abc
I need this format replicated to an excel sheet in the following way(column wise)
Name Age Work.Personal Work.Buisiness Work.Official
BS 66 xyz xyz NULL
AA 66 NULL abc abc
Remember the HTML page has around 1200 pages ie may be around 50,000 rows. And some times the column heirarchy for eg: work can be more like work-official-buisiness-abc-abc----. So taking data from each td is making the task that much difficult.
How can i meet this requirement?
And also since it is HTML page there is no runat = server for table. in this case how can i get the TD,TR,TABLE etc inside my server side code if i want to loop thorugh each TD and TR.
Please give me a solution which can meet this requirement.
Or with any other languages this can be met? i mean by Javascript or Java or etc???
Please help.
Thanks in advance.
Biju Sam
|
|
|
|
|
Biju Sam wrote: And also since it is HTML page there is no runat = server for table. in this case how can i get the TD,TR,TABLE etc inside my server side code if i want to loop thorugh each TD and TR.
Did you generate this table ? If so, who cares how it's run ? If not, how would a runat=server help you?
I guess you need to use a regex or something to parse the pages and get the data you need
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|