|
Hi
I thought I had sorted this but I was wrong.
Basically Ive need to get a column value for the current row I am trying to update. The update is happening on a dropdownselectedchange click event. I thought that if I added in:
string strID = GridView1.DataKeys[x].Values[1].ToString();
it would work but it doesnt perform the update. I need to get another column id for the current row I am updating
any help on this would be great
thanks!
public void dd_OnSelectedIndexChanged(object sender, EventArgs e)
{
for (int x = 0; x < GridView1.Rows.Count; x++)
{
GridViewRow row = GridView1.Rows[x];
string strID = GridView1.DataKeys[x].Values[1].ToString();
SqlCommand cmd_update_activity_order = new SqlCommand("update_activity_order", con);
cmd_update_activity_order.CommandType = CommandType.StoredProcedure;
|
|
|
|
|
if you are trying to update only one row, Why there is a for loop inside SelectedIndexChanged event.
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
because another person on this forum told me to do it.
Do you know how I can get the current selected dropdownlist value and the another column value from the same row?
|
|
|
|
|
.netman wrote: current selected dropdownlist value
Because of you are going to do this in the SelectedIndexChange event,
You can you the 'sender', convert sender to dropdownlist and use selected value.
.netman wrote: another column value from the same row
How you are going to identify the current row(index of the row)?
If you know then, What is the problem of getting the value?
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Sherin Iranimose wrote: You can you the 'sender', convert sender to dropdownlist and use selected value.
Can you explain what you mean by sender
Sherin Iranimose wrote: How you are going to identify the current row(index of the row)?
I'm not sure how to get the current row values e.g. another column
|
|
|
|
|
.netman wrote: Can you explain what you mean by sender
I was talking about the sender object in the OnSelectedIndexChanged Event handler
In the OnSelectedIndexChanged Event, you can use something like below...
DropDownList dropdown=(DropDownList)sender;
dropdown.SelectedValue <-- gives the selected value
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
.netman wrote: I'm not sure how to get the current row values e.g. another column
One way of doing this is to store the row number in the value field of the dropdown,
Eg:
in first row dropdown
Text value
1 1_1
2 2_1
3 3_1
4 4_1
1_1 will change to 1_2,2_1 to 2_2 and so on in the second dropdown
If you select 4 from 3rd row you will get 4_3 as value
So that you can retrieve the row index from this value field as follows
string val=drop.SelectedValue;
string rowNum=val.Substring(val.IndexOf("_")+1);
Hope this will help you
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Use DataKeyMember and DataKeyValue in your GridView.
In the OnSelectedIndexChanged(object sender, EventArgs e)
DropDownList ddl = (DropDownList)sender;
GridViewRow row = (GridViewRow)ddl.NamingContainer;
In that case you have the data of the GridViewRow that caused the Event.
GridView.SelectedIndex = row.RowIndex;
You know know the rownumber and with GridView.SelectedValue you know the DataKeyValue.
AT the end of the Eventhandler you state:
GridView.SelectedIndex = -1;
Good Luck
|
|
|
|
|
Good evening
i done the setting in web.config
<anonymousidentification enabled="true">
cookieTimeout="120000"
cookieRequireSSL="false"
cookieSlidingExpiration="true"
cookieProtection="Encryption">
and assign it in variable like
string temp=HttpContext.Current.Request.AnonymousID.ToString();
but AnonymousID contains null value.
what am i doing wrong don't know same code run on another system on same Application.
thanks
s am
Web Developer
|
|
|
|
|
Have you got cookies disabled?
|
|
|
|
|
No I have all ready enable cookies
Web Developer
|
|
|
|
|
No I am all ready enable cookies
Web Developer
|
|
|
|
|
i want to convert the any video file into .flv format.. it is worked local server perfectly.. but it is not worked in web server... security exception will be displayed.. i used ffmpeg.exe tool only... pls help me
Process ffmpeg; // creating process
string video;
string mpg;
video = Page.MapPath("movie.wmv");
mpg = Page.MapPath("") + "\\video.flv"; // thumb name with path !
ffmpeg = new Process();
ffmpeg.StartInfo.Arguments = "-i " + video + " -f flv -vcodec flv -qscale 10 -s 480x360 -ar 44100 -acodec libmp3lame " + mpg; // arguments !
ffmpeg.StartInfo.FileName = Page.MapPath("ffmpeg.exe");
ffmpeg.Start();
i receive this error what is this error tell me pls
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request failed.
Source Error:
[No relevant source lines]
Source File: App_Web_1lwzeoop.0.cs Line: 0
Stack Trace:
[SecurityException: Request failed.]
_Default.Button1_Click(Object sender, EventArgs e) +0
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.default_aspx.ProcessRequest(HttpContext context) in App_Web_1lwzeoop.0.cs
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
|
|
|
|
|
Assuming you are running this from a web page, you do not by default have permission to write to the file system, so I suspect that is your problem.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
what is the solution of this problem
|
|
|
|
|
Grant the necessary permissions on the applicable folders.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
i have a two dimensional array of string[,] i want to convert or fill it into the dataset or datatable
and also i need to fill with null value also
iam unable to do this
i tyed this
dataset.Tables.Add(Original_Table); //error says string[*,*] cannot be converted to datatable
Please help me.
Bharani
|
|
|
|
|
You need to create a datatable and add your data to it, you cannot cast an array to a datatable. If you want to allow nulls in the columns you will have to decalre them as nullable too.
This should get you started
dt = new DataTable();
dt.Columns.Add(new DataColumn("x", typeof(String)));
DataRow dumRow = dt.NewRow();
dumRow[0] = "All";
dt.Rows.Add(dumRow);
Bob
Ashfield Consultants Ltd
|
|
|
|
|
well I don't know about casting, as per previous answer, but you can certainly bind an array to a datatable... clickety[^]
|
|
|
|
|
I have a datalist that there is a picture control in it.name of the picture is in database and the picture in a folder on server. how can I change the size of picture that I show in datalist?
|
|
|
|
|
Can you not set the width of the columns of the datalist?
Or once you get the picture you can then convert to image type and edit the dimensions that way.
I think though not 100% sure
|
|
|
|
|
hi! guys this is terrible since a while now i've trying to do a very basic data binding, but i'm failing somewhere.let say in my webpage i have a dropdownlist and a textbox(textArea).so the logic is when a user select a text on the dropdownlist(ddCustom by id) its value should be displayed in the textbox.that it.what i've achieved so far is having the dropdownlist text bound but the value is not loading into the textbox field.
here are my codes
<code>
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string result = this.validateAll(txtEmail.Text, txtNumbers.Text, txtMessage.Text, txtName.Text, 100);
int resultlen = result.Length;
lblError.Text = resultlen.ToString();
}
else
{
DataSet DsTemplate = new DataSet();
DsTemplate.ReadXml(MapPath(@"~\misc\MessageTemplate.xml"));
ddCustom.DataSource = DsTemplate;
ddCustom.DataTextField = "name";
ddCustom.DataValueField = "text";
ddCustom.DataBind();
}
}
protected void ddCustom_SelectedIndexChanged(object sender, EventArgs e)
{
//txtMessage is the id of the textbox
txtMessage.Text = ddCustom.SelectedItem.value;
}
</code>
sample of the xml file
<?xml version="1.0" encoding="utf-8" ?>
<templates>
<template>
<name>Custom</name>
<text></text>
</template>
<template>
<name>Please call</name>
<text> i'm having a Problem Please call me back at</text>
</template>
<template>
<name>Meeting</name>
<text> the meeting is reported</text>
</template>
<template>
<name>BitrhDay</name>
<text> Happy birth Day</text>
</template>
</templates>
simple isn't it? but don't know.
I'm from php backgroung.i would do that by an ajax stuff or with jquery.But here i'm surely forgetting something or thinking that asp.net would do everything for me.i search on google, w3school and my codes seems to be ok.need help on this.please let me know as soon as you have time to check this.Thank you!
PS:i'm so frustrated i can't do anything else<code></code>
eager to learn
<div class="ForumMod">modified on Friday, July 11, 2008 7:39 AM</div>
|
|
|
|
|
common guys a little help to put me on track please.still waiting
eager to learn
|
|
|
|
|
Add this at the end of Page_Load
ddCustom.Attributes.Add(
"onchange",
"var txtMessage = getElementById('" + txtMessage.ClientID + "');"+
"if(txtMessage)txtMessage.value = this.options[this.selectedIndex].value"
);
This will run on client side.
Your code should also work, but you didn't give us the html from the ASP.NET page.
So... I suppose you did not assign the OnSelectedIndexChanged="ddCustom_SelectedIndexChanged" for your ddCustom <asp:dropdownlist ...="" xmlns:asp="#unknown"> control.
|
|
|
|
|
Pretty pretty cool man it's working without any modification.just copy and paste.You are the man!
thanks.
disturbingly simple.By the way why do you select txtMessage.ClientID instead of txtMessage what i would be tempted to do?
eager to learn
|
|
|
|