A couple of Data Grid questions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

1. Can the columns of the grid be accessed by the name of the data column they represent (e.g.Columns("StudentId"))

2. Can automatically added columns be accessed programmatically at all

3. My grid is populated by a dataset returned by a web service so data source and data member are set at run time. One post retrieves the data set. The next post will update a row. Does the grid data persist across posts

4. Can the grid be edited without the edit button column

5. Must the edit button be handled by server side code

mklapp
 
1. Can the columns of the grid be accessed by the name of the data column
they represent (e.g.Columns("StudentId"))?
yes for the most part (no for autogenerated grids)
2. Can automatically added columns be accessed programmatically at all? yes
3. My grid is populated by a dataset returned by a web service so data
source and data member are set at run time. One post retrieves the data
set. The next post will update a row. Does the grid data persist across
posts?
A web service does not cause a postback so the datagrid will persist its
data. If there is a post however, unless you cache the data, it will be
lost.
4. Can the grid be edited without the edit button column?
Sure, but you would have to manually build the functionality which comes for
free
5. Must the edit button be handled by server side code?
No, you can edit client side. But that requires advanced programming and a
healthy knowledge of scripting.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
mklapp said:
1. Can the columns of the grid be accessed by the name of the data column
they represent (e.g.Columns("StudentId"))?
2. Can automatically added columns be accessed programmatically at all?

3. My grid is populated by a dataset returned by a web service so data
source and data member are set at run time. One post retrieves the data
set. The next post will update a row. Does the grid data persist across
posts?
 
1. Can the columns of the grid be accessed by the name of the data column they represent (e.g.Columns("StudentId"))

Not in the way you are asking for. But as you are binding(handling the ItemDataBound event) to the datagrid you can access it thru dataview which has column names from your datatable
Once it's bounded to the grid then I think only way is to iterate thru the datagrid items and access the actual table cells by their index value
If you use templated columns with asp.net server controls then you can iterate thru the datagrid items and use the FindControl method to access the templated column controls
2. Can automatically added columns be accessed programmatically at all

See my suggestions to your question 1
3. My grid is populated by a dataset returned by a web service so data source and data member are set at run time. One post retrieves the data set. The next post will update a row. Does the grid data persist across posts

Yes the viewstate(by default EnableViewState is set to true in an aspx/ascx page) will persist the data. But if you the update to show up in your grid then you'll have to rebind with your webservice data
4. Can the grid be edited without the edit button column

I suppose you can do it by using template columns with asp.net button control. But it still may have to go thru as an event of the grid
Then again you can use Javascript. But it can be nasty
5. Must the edit button be handled by server side code

Not sure I understand this question.
ASP.NET Datagrid uses Javascript which submits your form and emits some details about the controls that caused the submit. The only thing I've seen people do is use edit button to confirm the users intention but other than that I'm not sure what use Edit buttom may have by not having a server side handler

If you haven't already done so visit the following links for details on the DataGrid control
http://samples.gotdotnet.com/quickstart/aspplus/doc/webdataaccess.asp
http://samples.gotdotnet.com/quicks...rms/ctrlref/webctrl/datagrid/doc_datagrid.asp

HTH
Suresh

----- mklapp wrote: ----

1. Can the columns of the grid be accessed by the name of the data column they represent (e.g.Columns("StudentId"))

2. Can automatically added columns be accessed programmatically at all

3. My grid is populated by a dataset returned by a web service so data source and data member are set at run time. One post retrieves the data set. The next post will update a row. Does the grid data persist across posts

4. Can the grid be edited without the edit button column

5. Must the edit button be handled by server side code

mklapp
 
Hi mklapp,

Does the community's reply make sense to you?

If you still have anything unclear, please feel free to feedback, I will
help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top