|
Hi,
I have a column in my DataGrid which represents a foreign key. At the moment, it displays the ID for that key. I want it to display another column instead..
For example:
User Table has (ID, Title, Firstname, Lastname)
Title Table has (ID, Mr, Mrs)
I want the data grid to show "title" as "Mr" or "Mrs" instead of "01" or "02",
Please help, Thanks!
|
|
|
|
|
Try this......
go to Datagrid property builder.. select the Bound column for ID and set its Text Field as Mr or Ms but DataField as ID
should work
Sanjeev
|
|
|
|
|
Sorry I should have been clearer...
The Title Table is expandable. So "Ms" and "Miss" and say "Master" can be added at a later date. This means the Column will be able to display the "title" dynamicly by querying the Title Table.
Otherwise, the senario would be that I would just be able to input "Mr" and "Mrs" as regular strings.
My issue is how exactly to query the table. I know I have to use an SQL View, but my efforts have been in vain
|
|
|
|
|
put your code in The ItemDataBound Event of the Datagrid.
Thanks & regards,
Suresh Dayma
Everything Is Possible!
|
|
|
|
|
Here is the code from ASP.NET 1.1 that works. My problem is below with 2.0 GridView?
private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int playerID = Convert.ToInt32(e.Item.Cells[1].Text);
string sqlDelete = "delete Players where PlayerID = '" + playerID +"'";
SqlConnection conn = new SqlConnection(dsn);
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = sqlDelete;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
DataGrid1.EditItemIndex = -1;
BindGrid();
}
This above code is ASP.NET 1.1 code for Deletion from DataGrid. It works fine. Now, I am using GridView (ASP.NET 2.0) The problem I am having is getting the playerID from GridView?
***int playerID = Convert.ToInt32(e.Item.Cells[1].Text); **
does not give any playerID but throws error? How do I get the playerID from GridView. Is the event handler Row Deleting or Row Deleted?
Please help.............
-- modified at 16:34 Wednesday 27th September, 2006
Sanju
|
|
|
|
|
could you please post the error message you're getting?
|
|
|
|
|
Thanks for you immediate reply........
Here is the error !!!
'System.Web.UI.WebControls.GridViewDeleteEventArgs' does not contain a definition for 'Item'
How do I retrieve PlayerID from the GridView?
Thanks
Sanjeev
|
|
|
|
|
San, that is weird, it is the sam way I do it (in VB.net) under the DataGrid Delete or Edit item methods (ASP.NET 1.1) , honestly I never worked with an ASP.NET 2.0 GridView object before.
Sorry!
|
|
|
|
|
I want to pass TWO parameter to crystal report but it is always second one applied , I'd be pleased if anybody help me.Thanks
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Hi,
A simple question....
In my aspx page, i am having some LinkButtons, with CommandName property. When i click a control, the page will post back.
I wish to know, which control is the source of this Postback, during Page_Load event iteself? NOT in that LinkButton's Command event.
How to perform this?
Regards,
Jay
|
|
|
|
|
|
Hi,
It works fine. I ve just used C#. But i have another query.
It says that,
Dim ctlName As String = targPage.Request.Form("__EVENTTARGET")
does not work if the postback is caused by standard buttons.
can u explain me the reason.
Thanks.
Regards,
Jay
|
|
|
|
|
hi
i need to get a value of html hidden control which is not set to runat server and i also dont have its id only name is getting.
Request.form["refid"] is not working. so
can u sugges some idea
regards
max
|
|
|
|
|
add runat="server" (from the html view) as a property of your hidden field, it will continue to work as a hidden field and it will allow you to read its value in the code behind. It might have a different way to solve this issue but this worked for me. Let me know if it works for you.
|
|
|
|
|
Dont mistake me, i have an small doubt, did you declared the tag inbetween the tags???? Because all other things are correct.
Know is Drop, Unknown is Ocean
|
|
|
|
|
Exelioindia,
Yes; like I said on my reply, it might be a different approach to solve this issue but this worked for me.
|
|
|
|
|
If you have put the hidden field inside the form that you are posting, you can get the value using Request.Form.
---
b { font-weight: normal; }
|
|
|
|
|
it will be generated as a System.Web.UI.HtmlControls.HtmlInputHidden and you can acess (get/set) its value using: fieldName.value.
David
|
|
|
|
|
dgonzale wrote: it will be generated as a System.Web.UI.HtmlControls.HtmlInputHidden and you can acess (get/set) its value using: fieldName.value.
Only if you add the runat and id properties to the element. Otherwise the element is treated as plain text by the server.
There is no need to make a server element of it to access the value that it sends in the post.
---
b { font-weight: normal; }
|
|
|
|
|
Ooops! Yes you're right, i forgot about the id property, thanks Guffa.
David
|
|
|
|
|
Hi to all,
I need to POST To A Different Site in asp.net (vb.net) after users enter required data filds in a form. Specifying action (containing the URL of the site) and the target (_blank) does not help, it opens my site again.
I’ll appreciate any help,
Regards,
David
|
|
|
|
|
in the form's action specfiied fully qualified URL of the page which it has to call such as
<form method="post" action="http://callingsite.com/authen.aspx">
and verify the field/value names that you are passing to the page are similar or not.
If this one not a solution, be specific of what are you doing and how you are doing it?
|
|
|
|
|
Hi Rao, thanks for such a prompt reply.
I tryed this already and it opened my application again on the new browser window.
<form id="Form1" method="post" runat="server" action="http://callingsite.com/authen.aspx" target="_blank">
Fields were identified as requested by the target site according to a sample HTML form I found. I also tryed with plain HTML input objects an a plain HTML form and it worked, since I'm inheriting from a base form class, this will not work.
David
|
|
|
|
|
remove runat="server" attribute
|
|
|
|
|
Like I said, I tryed using a PLAIN HTML form and it worked but this will prevent the rest of the objects in the form to work, besides I'm inheriting the form from a form base class and this won't work either .
Can I have a ASP.NET form object and a PLAIN HTML form at the same time? I would wrap any object inside the ASP.NET form and the 2 other fields inside the HTML form.
|
|
|
|