entry and edit mode in same form

Posted by Shailesh21235 under ASP.NET on 7/3/2012 | Points: 10 | Views : 2302 | Status : [Member] | Replies : 4
here i have created a mode works on padeload & this classs GetQueryStringValue returns a query;;

stringmode = GetQueryStringValue(HttpContext.Current.Request.QueryString["Mode"]);
string productId = GetQueryStringValue(HttpContext.Current.Request.QueryString["ProductID"]);
string temp = "localhost/admin/product.aspx?Mode=Edit&ProductID=1";

if (mode.Equals("Edit")
{}
else (mode.Equals("Insert"))
{}

whle entering in edit mode there is no value so it skips the step...how to enter in these modes to edit or insert datas in same button click????




Responses

Posted by: Sheonarayan on: 7/3/2012 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
I feel the code you have written is not proper. Instead of having the mode in querystring you can store some flag in the ViewState and use this to decide edit or insert mode.

Even you use above code, I really do not understand what GetQueryStringValue is doing there as you have already passed the exact code to retrieve the querystring. Perhaps you just need to pass "Mode" in this method and it will return you the querystring value.

Hope this helps.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Shailesh21235, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muralidosscm on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
if (mode.Equals("Edit")
{}
else (mode.Equals("Insert"))
{}

if else condition is wrong............

put the code clearly


Regards
Muralidoss M

Shailesh21235, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
int pageid = Convert.ToInt32(Request.QueryString["Mode"].ToString().Trim());
if (mode.Equals("Edit")
{
//Execute query and save in dataset
DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, "select *,(cast(regionID as varchar) +','+ cast(countryId as varchar) +','+ cast(cityid as varchar)) as id from vwDestinationLocation order by location");

//Fill the input boxes
txtWDesc.Value = dsContent.Tables[0].Rows[0]["WeatherDesc"].ToString();
txtHDesc.Value = dsContent.Tables[0].Rows[0]["HistoryDesc"].ToString();
txtVdesc.Value = dsContent.Tables[0].Rows[0]["VisitDesc"].ToString();

// After this run the update query.

}
else (mode.Equals("Insert"))
{
//here run the insert query.

}


ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Shailesh21235, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shailesh21235 on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
hey thanks,
but is it possible to enter in edit or insert mode in page load or can be done only by button press in product.aspx page????

i have done done in the page just by pressing edit or insert button.......

how to direct it to the modes in pageload.....

Shailesh21235, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response