MVC model not saving the value [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
var ticketnumber = TempData["ticketId"] as Ticket;
ticketnumber.TicketId = model.TicketId;
db.SaveChanges();
HttpPostedFileBase file = Request.Files["ImageData"];
UploadRepository service = new UploadRepository();
int i = service.UploadImageInDataBase(file, model);
I have the value inside my tempdata but when i try to assign the value of it to the model value it doesnt save and even in debug it tells me the value hasnt changed so i just dont get what i am doing wrong.

You need to change the assignment:
From:
ticketnumber.TicketId = model.TicketId;
To:
model.TicketId = ticketnumber.TicketId;

Related

How to add variable in the object in C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
var data = #"{
""owner1"":""Name"",
}";
Need to add variable in the above object in c#
If your data is json string, you can modify it by JObject like this:
var jsonData = JObject.Parse(data);
jsonData["owner1"] = "owner1";
jsonData["owner2"] = "owner2";

C# Get Object Values [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm new to C#.
I have a method that returns an object with the List of objects inside.
0 {{DapperRow, RecordedFormID = 'id1'}} object {Dapper.SqlMapper.DapperRow}
1 {{DapperRow, RecordedFormID = 'id2'}} object {Dapper.SqlMapper.DapperRow}
How can I get those ids as strings?
Here is a screenshot
You can use System.Linq namespace and do this:
yourObject.Select(x => x.RecordedFormID);

Input string was not in a correct format in gridview [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am updating the values in grid view. if i am updating the noofdays it will showing Input string was not in a correct and how to give me some suggestion.
and i have other question when the employee apply leave before week it will take the data else it will show the message.
how to write it logic.
code behind
leaveUpdateRow.NoOfDays = Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text);
ASPX
<asp:BoundField DataField="NoOfDays" HeaderText="Leave Period"></asp:BoundField>
Try this
leaveUpdateRow.NoOfDays = Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text) == NULL ? 0 :Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text);
Try it
please check the value is integer before convert the values.
Use string.IsNullOrEmpty
leaveUpdateRow.NoOfDays=string.IsNullOrEmpty(((TextBox)(row.Cells[4].Controls[0])).Text)?0:Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text);

Can I create a Request object by a URL? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a URL, such as http://www.mydomain.com/?param1=asd2&param2=asd2.
I'd like to create a sort of Frequest object, so than I can easily do somethings like:
Request.Querystring("param1")
without do a further Split and access to the array. Can I?
Your question is not clear. Are you looking something like this?
var uri = new Uri("http://www.mydomain.com/?param1=asd2&param2=asd2");
var nv = uri.ParseQueryString();
Console.WriteLine(nv["param1"]);
EDIT
It seams one of my referenced libraries implemented this extension Method. Anyway, it can be done as
var uri = new Uri("http://www.mydomain.com/?param1=asd2&param2=asd2");
var nv = HttpUtility.ParseQueryString(uri.Query);
Console.WriteLine(nv["param1"]);

Query String operator assignment error [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm going to send back data to my sms gateway.first i have a querystring like this.
string mobileNo = Request.QueryString["msisdn"];
int dest = int.Parse(Request.QueryString["shortcode"].ToString());
string messageIn = Request.QueryString["msg"];
string operatorNew = Request.QueryString["operator"];
Then i'm going to assign a variables to it.
public void sendReply(string messageOut)
{
messageOut = "http://mygateway.com/api/mt?msisdn=mobileNo&body=msg&sender=shortcode&key=nvqow9rhfp&product_id=2116&operator=OperatorNew&country=us";
}
But i'm getting operator assignment error..
Check this.This parameter is wrong.this param not supplied.
&body=msg
Please verify your Key & Product id with the gateway owners.

Categories