|
Here is one solution but in this case your page will be post back.
set PostBackTrigger to that button id.
<triggers>
<asp:postbacktrigger controlid="ImageButtonID" />
</triggers>
please don't forget to vote on the post that helped you.
|
|
|
|
|
Thank you for replying...
Bur here problem is that... on runtime more that one item is creating in datalist so we can't use that button id because that id gone change in runtime.
krishna veer singh
|
|
|
|
|
I have a dropdownlist control in my gridview
When somone chooses an option from it an event is ran
I need to get a datakey for that row, how would I do that?
thanks
|
|
|
|
|
Try this
string str = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Values["here datakeyname"].ToString();
and in the source, for CommandArgument..
CommandArgument='<%#((GridViewRow)Container).RowIndex %>'
krishna veer singh
|
|
|
|
|
The event that is firing is an onclick event for the dropdownlist
Therefore
string str = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[""].ToString();
does not work because there is no command arguement for it
is there another way?
thanks
|
|
|
|
|
.netman wrote: The event that is firing is an onclick event for the dropdownlist
Therefore
string str = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Values[""].ToString();
Post your code where you create event handler of dropdownlist and dropdownlist event also
please don't forget to vote on the post that helped you.
|
|
|
|
|
DropDownList dr = (DropDownList)sender;
string str = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Values["code"].ToString();
SqlCommand cmd_update_order = new SqlCommand("update_order", con);
cmd_update_order.CommandType = CommandType.StoredProcedure;
cmd_update_order.Parameters.Add(new SqlParameter("@order", SqlDbType.Int));
cmd_update_order.Parameters["@order"].Value = dr.SelectedValue;
cmd_update_order.Parameters.Add(new SqlParameter("@code", SqlDbType.VarChar));
cmd_update_order.Parameters["@code"].Value = str;
str should be the datakey but it is not working
thanks
|
|
|
|
|
.netman wrote: DropDownList dr = (DropDownList)sender;
string str = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Values["code"].ToString();
You can not get CommandArgument here
Set that in ToolTip property of dropdownlist when you create evend handler of DDL
On RowCreatedEvent
DropDownList ddl=(DropDownList)e.Row.FindControl("DDLID");
ddl.ToolTip=gv.DataKeys[e.Row.RowIndex].Value;
Now on SelectedIndexChange event
DropDownList dr = (DropDownList)sender;
string keyID=dr.ToolTip
....
.....
please don't forget to vote on the post that helped you.
|
|
|
|
|
error:
Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)
ddl.ToolTip = GridView1.DataKeys[e.Row.RowIndex].Value; // gv is your gridview
it throws an error for this line
How do I convert?
|
|
|
|
|
ok I changed to
ddl.ToolTip = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
and it now it shows
Index was out of range. Must be non-negative and less than the size of the collection.
why would this be?
cheers
|
|
|
|
|
Use the NamingContainer property of your DropDownList
So in your OnSelectedIndexChanged you can state
(GridViewRow) row = (GridViewRow)ddl.NamingContainer;
After that you can set
GridView.SelectedIndex = row.RowIndex;
At the end of the event add a line:
GridView.SelectedIndex = -1;
you do this to prevent showing a GridView with a Selected Line in it.
|
|
|
|
|
Plz tell me is it possible to use hiddenfield with session object.i am taken some values through session and some by hidden fields.at third page it is not taken the correct value of the session variable .
thanks...gaurav
|
|
|
|
|
By debugging, check your session value where it is getting changed.
Balasubramanian K.
|
|
|
|
|
Hi all,
can someone plz help me...im trying to load my page frmHome.aspx in my ContentPlaceHolder...can anyone help please.
living life on the flip side
|
|
|
|
|
did you select 'Load Masterpage' when creating this page?
|
|
|
|
|
Hi Team,
I have created a application in Visual Studio 2005.Its a Simple application with one master page and some static pages and I have Deployed this appication on server. But i am getting this error
"The codefile attribute on the page directive is not allowed in this page."
I am not getting why i am getting this error.
Please reply me.
I need to run the application as soon as possible.
Thanks and Regards
Avesh Agarwal
|
|
|
|
|
I'm trying to deploy my asp.net 2.0 on windows server 2003. The login page of the web application (default) works fine but when I try to login, the page keeps loading and loading for a long time and I never accesses the pages after login. No error is displayed or anything the browser just hangs as if it's trying to access the page.
I'm using the membership api in asp.net and I installed the ajax extensions on the server and I created a virtual directory in the iis.
what's wrong?
|
|
|
|
|
Please check the server even viewer to see whats the error. Post whats happening else its almost impossible to help you out I guess.
Thanks,
Arindam D Tewary
|
|
|
|
|
Hi guys its one challenging problem in gridview...,
If any one will get solution regarding this reply me immediately...,
Plz go through it...,
Thank u...,
I am trying to allocate width for my gridview columns...,
In my rowdatabound i given
e.row.cells[3].width=Unit.Pixel(100);
e.Row.Cells[3].Wrap = true;
Its not at all considered the values, what i have allocated the cell...,
Based on grid total width its automatically allocated the width for cells...,
So i changed my code like this:
e.Row.Cells[3].Attributes.Add("width", "100px;");
Its worked cool...,
Now my probs is, suppose the text is continious text...,
That time its not warpping the text based on the allocated width...,
Eg text like this : copy_text_normal_ppojkjbjhjh_bvjhvkv_jnvjhb.txt
Now this text having no gap between the letters...,
In that case its not at all wrapping my text based on the width of the cell,
How to solve this probs
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
try using this, for example
<asp:BoundField DataField="OrderID" HeaderText="OrderID" SortExpression="SortOID" NullDisplayText="none" ItemStyle-Wrap=false/>
|
|
|
|
|
no its auto generate columns...,
I cant define like that...,
I have to tell all those things in runtime only
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
New one wrote: Now my probs is, suppose the text is continious text...,
That time its not warpping the text based on the allocated width...,
Eg text like this : copy_text_normal_ppojkjbjhjh_bvjhvkv_jnvjhb.txt
Now this text having no gap between the letters...,
In that case its not at all wrapping my text based on the width of the cell,
Generally in this situation,Overflow style can be used.
You can add overflow attribute style and set it as scroll or hidden.
i.e
e.Row.Cells[3].Attributes.Add("overflow","scroll");
OR
e.Row.Cells[3].Attributes.Add("overflow","hidden");
regard
kHan
please don't forget to vote on the post that helped you.
|
|
|
|
|
hi all,
i use an ajax radgrid and i want to convert it to Excel Sheet, this error appear when i do that,
unexpected ajax response was recived from the server.
this may be caused by one of the follwoing reasons:
- server. transfer
-custom http handler
-incorrect loading of an "Ajaxified" user control.
how can Solve this error??/
thanks all
|
|
|
|
|
I have taken a DataList then Its dispaly value properly.. But i want to take another DataList in Item Template of First DataList. Ya I can Take any another data control just like.. Datagrid, Repeater.etc in Item Template of First DataList..
|
|
|
|
|
Hi,
Yes, you can use another DataList inside the first DataList's ItemTemplate field.
Thx,
Gayani
|
|
|
|