Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

How to: Load data in gridview without DataSource

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ircremer@hotmail.com - 21 Jan 2008 11:34 GMT
Hello,

First, sorry for my English...

I'm triying to load data from store procedure into a gridview.

The most simply is doing 'myGrid.DataSource = myDataTable', but this
'myDataTable' returns a numeric value that I need to transform (this
numeric value is an ID, and i need the description of this ID, that is
store in another table in my DB)

My Gridview has 3 BoundsFields and one TemplateField for this
'problematic' column, whit a Label:

<Columns>
<asp:BoundField DataField="xxxx" HeaderText="xxxx" />
<asp:TemplateField HeaderText="xxxx">
       <ItemTemplate>
            <asp:Label ID="xxxx" runat="server"></asp:Label>
       </ItemTemplate>
</asp:TemplateField>
...

I need a idea, because I'm looking for it in google and msdn but no
'good results'... (in ASP .NET)

Thanks.

Now In Spanish:

Hola,

Estoy intentando cargar los datos de un procedimiento almacenado en un
gridview. Obviamente lo más sencillo es hacer un 'gridview.DataSource
= myDataTable' y que lo haga automáticamente. El problema es que la
consulta ejecutada, me devuelve un campo ID que tendria que
transformar en su descripcion para poder mostrar eso al usuario.

Como se detalla arriba, uso un gridview con BoundsFields para los
campos que no necesito tocar, y un TemplateField para este campo, ya
que no busco asignarlo directamente de la BD.

Necesito alguna idea porque todo lo que he buscado por google y msdn
no indica nada parecido para resolverlo. (en ASP . NET)

Gracias.
Peter Bromberg [C# MVP] - 21 Jan 2008 11:49 GMT
<asp:Label ID="xxxx" runat="server" Text='<%# Eval("myID") %>'
></asp:Label>

Your question should be posted to the asp.net group, this is the C# language
group.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com 

> Hello,
>
[quoted text clipped - 42 lines]
>
> Gracias.
luukas9 - 21 Jan 2008 11:56 GMT
Thanks for your response, and sorry for my error... I'm not habit for
this site...

Your response isn't that I'm looking for... but thanks.

I'll move my question for the asp .net group.
Ignacio Machin ( .NET/ C# MVP ) - 21 Jan 2008 13:37 GMT
Hi,

Is myDataTable really a DataTable? if so it returns a table, not a value.

What you can do is in the SP add another column for the value of that ID:

select product.*, category.Name from products P inner join Category C on
P.categoryID = C.Id

Signature

Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.

Hello,

First, sorry for my English...

I'm triying to load data from store procedure into a gridview.

The most simply is doing 'myGrid.DataSource = myDataTable', but this
'myDataTable' returns a numeric value that I need to transform (this
numeric value is an ID, and i need the description of this ID, that is
store in another table in my DB)

My Gridview has 3 BoundsFields and one TemplateField for this
'problematic' column, whit a Label:

<Columns>
<asp:BoundField DataField="xxxx" HeaderText="xxxx" />
<asp:TemplateField HeaderText="xxxx">
       <ItemTemplate>
            <asp:Label ID="xxxx" runat="server"></asp:Label>
       </ItemTemplate>
</asp:TemplateField>
...

I need a idea, because I'm looking for it in google and msdn but no
'good results'... (in ASP .NET)

Thanks.

Now In Spanish:

Hola,

Estoy intentando cargar los datos de un procedimiento almacenado en un
gridview. Obviamente lo más sencillo es hacer un 'gridview.DataSource
= myDataTable' y que lo haga automáticamente. El problema es que la
consulta ejecutada, me devuelve un campo ID que tendria que
transformar en su descripcion para poder mostrar eso al usuario.

Como se detalla arriba, uso un gridview con BoundsFields para los
campos que no necesito tocar, y un TemplateField para este campo, ya
que no busco asignarlo directamente de la BD.

Necesito alguna idea porque todo lo que he buscado por google y msdn
no indica nada parecido para resolverlo. (en ASP . NET)

Gracias.
luukas9 - 21 Jan 2008 14:46 GMT
Hi.

myDataTable exist in my file xsd. The problem I have with your
solution is that:

       Table: Employee
       Fields: IDEmployee (int), Name (varchar), Surname (varchar),
IsBoss (varchar), IDEmployeeBoss (int)

In my SELECT, I filter by IDEmployee. When I execute the store
procedure, it returns {1,'name01', 'surname01', false, 2} {2,'boss01',
'surname02',true, null}.

Then, in the case that I'll need the boss name y need to do something
(a new select filter by IDBoss) to get the boss name.

Temporarily, I've found a solution that consist in:
myDataTableResult.Rows[i]["IDEmployee"] =
SelectBossName(myDataTableResult.Rows[i]
["IDEmployee"].toString()).toString(); that modifies the return value
for this column with a new select that retries the boss name.

But the problem persist, because, it's only a temporarily solution.

Thanks for your response.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.