|
Hi
This may be a duplicate post but the first has gone on the other page so thought i would post so every1 can see it
Ive got a gridview, its got lots of columns binded to a database, one of the columns has an imagebutton in, when I click that imagebutton I want to get the value for another column but for the same row that was clicked.
How can I do that?
Ive searched google but nothing seems to be suitable
thanks in advance guys!!
|
|
|
|
|
If you want to get the value of any row you can do like this
GridView1.Rows[Index].Cells[Index].Text
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
OK
I tried this on the button click event
test.Text = GridView1.SelectedDataKey[0].ToString();
I thought this would work because I have datakeynames set in the gridview
but it shows the object reference error, however the textbox test exists so its like it doesnt find the selected datakey
With the example you gave above, I dont know what the indexs of the rows would be so how could I set that?
cheers for the reply!
|
|
|
|
|
1) I assume it shoudl be something like GridView1.DataKeys[index]
Because GridView1.SelectedDAtaKey will be null because you have't selected the row.
2) May be you can set the tagname or command name of the button to the index of the the row during binding.
So in the ItemCommand you can use this to find out the index.
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
hey
managed to get this to work
ImageButton btn = (ImageButton)sender;
GridViewRow row = (GridViewRow)btn.NamingContainer;
test.Visible = true;
test.Text = GridView1.DataKeys[row.RowIndex].Value.ToString();
But it only selects the first datakey in the list, is it possible to select a certain one?
cheers!
|
|
|
|
|
Try this
GridView1.DataKeys[row.RowIndex].Values[Index].ToString();
Or
GridView1.DataKeys[row.RowIndex].Values[KeyName].ToString();
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
Which Column you are using ?
If you are using Template column try this code in RowCommand Event.
textBoxt1.Text=((GridViewRow)(((Control)e.CommandSource).NamingContainer)).Cells[1].Text;
Thank & Regards
Vijay s
|
|
|
|
|
Hi,
I am using code behind aspx.cs
c#:
if (Request.Browser.Cookies)
lblBrowser.Text = "<b>Cookie Enabled</b>";
else
lblBrowser.Text = "<b>Cookie Disabled</b>";
Problem:
-I am using IE7 and from tools>Internet Option>privacy
-I am selecting Block All Cookies
-when again I am tring to run my code it showing cookie Eanbled.
Can U solve this problem or give me some relative code.
Thanks
Ashish
|
|
|
|
|
Request.Browser.Cookies tells whether browser supports the cookies or not...
it doesn't gives the value whether the cookies are enabled
I'm not sure if there is way to check it through ASP.NET, a simple javascript does it..
.....
|
|
|
|
|
The only way to check if a cookie is allowed, is to set it, and then on the next page check if you got it back from the browser.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hello sir
i am using datagrid control.
pls tell me how to add submit button on datagridview.
pls tell me detail.
gayatri
Gayatri
|
|
|
|
|
try this
<ItemTemplate>
<asp:Button CommandName="Delete" Text="Delete" ID="btnDel" Runat="server" />
</ItemTemplate>
|
|
|
|
|
add button in template column and assign a commandname to that button. in code behind, check for the commandname in rowcommand event.... then do whatever necessary
Ashish Sehajpal
|
|
|
|
|
hi,
I want to deploy my web application on a server but it recently crossed my mind that I'm using membership's aspnetdb so I was wondering what if the server already contains another asp.net 2.0 web application that also uses aspnetdb that is created by default. Will my database be overridden or what?
I believe also that the machine.config file has the connectionstring of this database, so what will happen when the aspnetdb is attached at runtime to sqlexpress on the server and at the same time there's another one with the same name for another application on the same server???
thanks
|
|
|
|
|
You can set the connection string for the ASPNETDB in Sql Express per application.
In IIS go to the ASP.NET tab Edit Configuration > General Tab. Your apps uses this to connect to the db that is specific to your appliction.
Also this settings overrides your Machine.Config file
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
hi all
Is there a way in web to use enter instead of tab to move between fields on a page? My client is a bit ....
thanks
|
|
|
|
|
Yeah, you need to handle keypress events in javascript and move the focus. Not a good idea, it's far better to stick to standards than invent your own UI.
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 )
|
|
|
|
|
Christian Graus wrote: Not a good idea, it's far better to stick to standards than invent your own UI.
Thanks Christian that was the exuse i was looking for....
|
|
|
|
|
*grin* glad to oblige
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 )
|
|
|
|
|
i am using form authenication. in that after loggin i am browing some page.
After that i logout the site. when i click the back button or put the url of the browsed page it opens as it.
please help me how to restrict it.
|
|
|
|
|
Your site should remember if a user is logged in, via the session. Every page should be derived from a base page that redirects to the login page if the user is not logged in.
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 )
|
|
|
|
|
I have been given the "opportunity" to expand my ASP.net coding skills but I have hit a dead end at the moment. What I need to do is create a form that is generated by two SQL server tables. Table one holds general categories and table two holds items under those categories. Both tables are linked by a common key column. I have successfully generated a form from a two table dataset linked using a relationship. The form places each category and associated items with checkboxes in an HTML table cell. I need to know if I can dynamically bind boolean column data to the checkboxes by somehow inserting the generated table in an editTemplate of the datalist. I think maybe I've gone about this backwards but I'll appreciate any help to get me moving again.
I hope the question is clear enough, thanks for any help.
|
|
|
|
|
I am developing 5 pages under one master page.
Now I want to prepare report using table tag.
The report show in next page.
The report page open in same window.
But I want to open report page in new window.
How to open in new window?
Please give your suggessions.
Thanking you.
abglorie
|
|
|
|
|
|
If you read all my responses, you'll see there are Indian developers I have nothing but respect for. Then there's this guy....
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 )
|
|
|
|