|
Hello All,
I am having a webform with two textbox and and one dropdownlist .. and one gridview
when i entered values in textbox and select dropdownlist value after that i click on save button then it will save in database.
and the display the textbox value and dropdownlist selected value in GridView what i taken in the same page .
The following code i wrote for in codebehind:
protected void Save_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Mfund_String"].ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into mfund_share_dtls values(" + this.TextBox1.Text + ",'" + this.ddlFund_name.SelectedItem.Value + "','" + this.ddlDOBdd.SelectedItem.Value + '-' + this.ddlDOBmm.SelectedItem.Value + '-' + this.ddlDOByyyy.SelectedItem.Value + "'," + this.txtNoUnits.Text + "," + this.txtPricePaid.Text + ")", con);
cmd.ExecuteNonQuery();
SqlCommand cmd1 = new SqlCommand("SELECT fund_no, usr_no, fund_name, dop, no_units, price_paid FROM mfund_share_dtls WHERE(usr_no = " + this.TextBox1.Text + ") AND (fund_no =(SELECT MAX(fund_no) AS Expr1 FROM mfund_share_dtls AS mfund_share_dtls_1 WHERE(usr_no = " + this.TextBox1.Text + ")))", con);
SqlDataReader dbdr = cmd1.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dbdr);
dbdr.Close();
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
So now i want in gridview edit... suppose the client mistakenly chosen wrong dropdownlist value and enterd wrong textbox value,
so now he want to edit the dropdownlist value and textbox value in gridview.
How i have to approach for gridview update through code behind and please guide me ...i need to display the dropdownlist also to select correct dropdownlist value in gridview update.
Many Thanks
Vijay
|
|
|
|
|
Hai,
I am using dotnetFramework1.1 with C# coding for my project.
I need to display some Records.So i use DataList Control For that...But my Problem is that when I click a particular row ,i want to redirect to some other page showing the full description of that particular record.How is this possible????....Please hepl me to solve my proble....
thanks in advance
Bijesh
|
|
|
|
|
Use Template Column in DataList control. Put the LinkControl in that template column.
OR
<a href="http://mysite/anotherpage.aspx?id=1" > <%# DataBinder.Eval(Container.DataItem,"fieldName") %></a>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hello,
i am new to asp.net.....By using "id=1" in query string How we can recognize each different recods data....I try this but some error comes....any modification need my code.......
<%# DataBinder.Eval(Container.DataItem,"fieldName") %>
--------------------------------------------------------------------------
>
<asp:button
="" style="display:none;" commandargument="<%# DataBinder.Eval(Container.DataItem,"AD_TITLE")%>" id="HiddenButton" runat="server" text="View">
<%# DataBinder.Eval(Container.DataItem,"AD_TITLE") %>
<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>
<%# DataBinder.Eval(Container.DataItem,"AD_DESCRIPTION") %>
Price:
<%# DataBinder.Eval(Container.DataItem,"PRICE") %>
Location:
<%# DataBinder.Eval(Container.DataItem,"LOCATION") %>
this is the code what i used or please help me by using template column link control.....
thanks in advance
|
|
|
|
|
<a href="http://mysite/anotherpage.aspx?id=<%# DataBinder.Eval(Container.DataItem,"fieldName") %>" > <%# DataBinder.Eval(Container.DataItem,"fieldName") %></a>
bijeshputhalath wrote: please help me by using template column link control.....
<asp:DataList id="DataList1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"><br />
<ItemTemplate><br />
<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl="<%# DataBinder.Eval(Container.DataItem,"fieldName") %>"><%# DataBinder.Eval(Container.DataItem,"fieldName") %></asp:HyperLink><br />
</ItemTemplate><br />
</asp:DataList>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hello,
Thank you so much....i use the first method.....it is working fine.....But in my query string, i send 3 parameters(Becoz if i send only one parameter if any records with same data i,it will display the first record)...But i cant retrieve it all the three and getting some error .
----------------------------------------------------------------------------
i used the following code in html
>
<asp:button
="" style="display:none;" commandargument="<%# DataBinder.Eval(Container.DataItem,"AD_TITLE")%>" id="HiddenButton" runat="server" text="View">
,price=<%# DataBinder.Eval(Container.DataItem,"PRICE") %>,type=<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>">
<%# DataBinder.Eval(Container.DataItem,"AD_TITLE") %>
<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>
<%# DataBinder.Eval(Container.DataItem,"AD_DESCRIPTION") %>
Price:
<%# DataBinder.Eval(Container.DataItem,"PRICE") %>
Location:
<%# DataBinder.Eval(Container.DataItem,"LOCATION") %>
----------------------------------------------------------------------------
and in my target page i use
string search,type1,price;
search=Request.QueryString["li"].ToString();
type1=Request.QueryString["type"].ToString();
price=Request.QueryString["price"].ToString();
Label1.Text=search;
string sstr="select * FROM ads where AD_TITLE='"+search+"' && PRICE='"+price+"' && AD_TYPE='"+type1+"'";
sdr=conobj.reader(sstr);
----------------------------------------------------------------------------
But i get the following error
Server Error in '/approvedplotfinal' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 45:
Line 46: search=Request.QueryString["li"].ToString();
Line 47: type1=Request.QueryString["type"].ToString();
Line 48: price=Request.QueryString["price"].ToString();
Line 49: Label1.Text=search;
----------------------------------------------------------------------------
Please help me to trace out.......
thanks again....
Biju
|
|
|
|
|
When you are posting the HTML code, please check "Ignore HTML tags in this message". otherwise, all code will be strips off..
Can you post your code again?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
this the target page URL:::
"http://localhost/approvedplotfinal/classified/AddView.aspx?li=search%20of%20a%20new%20plot,type=Wanted,price=5000"
My target page code like this-----------------------------------------------------------------------------
string search,type1,price;
//Session["li"].ToString();
search=Request.QueryString["li"].ToString();
type1=Request.QueryString["type"].ToString();
price=Request.QueryString["price"].ToString();
Label1.Text=search;
string sstr="select * FROM ads where AD_TITLE='"+search+"'&& AD_TYPE='"+type1+"' && PRICE='"+price+"' ";
sdr=conobj.reader(sstr);
while(sdr.Read())
{
}
----------------------------------------------------------------------------
This is the htmal part
<ItemTemplate>
<tr <%# TRJavaScript(Container) %> >
<td><asp:Button
style="display:none;"
CommandArgument='<%# DataBinder.Eval(Container.DataItem,"AD_TITLE")%>'
ID="HiddenButton" Runat="server" Text="View">
</asp:Button>
<a href="http://localhost/approvedplotfinal/classified/AddView.aspx?li=<%#DataBinder.Eval(Container.DataItem,"AD_TITLE") %>,type=<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>,price=<%# DataBinder.Eval(Container.DataItem,"PRICE") %>">
<%# DataBinder.Eval(Container.DataItem,"AD_TITLE") %>
</a>
<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>
<br>
<%# DataBinder.Eval(Container.DataItem,"AD_DESCRIPTION") %>
<br>
Price:
<%# DataBinder.Eval(Container.DataItem,"PRICE") %>
<br>
Location:
<%# DataBinder.Eval(Container.DataItem,"LOCATION") %>
<br>
</tr>
</ItemTemplate>
----------------------------------------------------------------------------
please help.....
i need to hit a target page with these parameters ....
thanks
Biju
|
|
|
|
|
bijeshputhalath wrote: li=<%#DataBinder.Eval(Container.DataItem,"AD_TITLE") %>,type=<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>,price=<%# DataBinder.Eval(Container.DataItem,"PRICE")
should be "&" (not ",") eg: http://myurl.com/page1.aspx?a=1&b=2&c=3
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hello ,
I try with "&" also Before your suggetion with & operator....But the same error comes still.....
my problem is that...How can i retrieve each query string value
li=<%#DataBinder.Eval(Container.DataItem,"AD_TITLE") %>&type=<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>&price=<%# DataBinder.Eval(Container.DataItem,"PRICE")
With these coding ,it will work or not????
string search,type1,price;
search=Request.QueryString["li"].ToString();
type1=Request.QueryString["type"].ToString();
price=Request.QueryString["price"].ToString();
Label1.Text=search;
string sstr="select * FROM ads where AD_TITLE='"+search+"'&& AD_TYPE='"+type1+"' && PRICE='"+price+"' ";
sdr=conobj.reader(sstr);
while(sdr.Read())
{
}
what is my mistake ...????Please help me....
with regards and thanks
Biju
|
|
|
|
|
Okay. Lets debug the application..
Let's say we have two pages called page1 and page2. We will divide the issue into small pieces ~
1. Using static data in page1
2. Retrieving the data in page2
3. Checking whether the SQL statment is correct or not
4. Changing static data to dynamic data in page1.
1. Using static data in page1
We will remove all dynamic value in A link to avoid NULL value and "".
Note: dynamic value means <%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>.
<a href="http://localhost/approvedplotfinal/classified/page2.aspx?li=<%#DataBinder.Eval(Container.DataItem,"AD_TITLE") %>,type=<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>,price=<%# DataBinder.Eval(Container.DataItem,"PRICE") %>"><br />
<%# DataBinder.Eval(Container.DataItem,"AD_TITLE") %><br />
</a><br />
We will replace all dynamic value with all static value.
<br />
<a href="http://localhost/approvedplotfinal/classified/page2.aspx?li=mytitle&type=mytype&price=100" ><br />
<%# DataBinder.Eval(Container.DataItem,"AD_TITLE") %><br />
</a>
Run the application to check whether there is any error or not.
2. Retrieving the data in page2
Forget about other code in page2. We will assume that we have only the following lines in Page Load.
search=Request.QueryString["li"].ToString();
type1=Request.QueryString["type"].ToString();
price=Request.QueryString["price"].ToString();
- Set the breakpoint at "search" variable.
- Run the application. (Page1 is start-up page)
- Click the link in page1. (it will take you to page2.)
- Check whether "Request.QueryString["li"] " is null or not.
- Check whether "Request.QueryString["type"] " is null or not.
- Check whether "Request.QueryString["price"] " is null or not.
Note: All three parameters should not be NULL. If you are getting NULL then let me know.
3. Checking whether the SQL statment is correct or not
Which Database are you using? If it's SQL Server, you don't need "&&".
string sstr="select * FROM ads where AD_TITLE='"+search+"'&& AD_TYPE='"+type1+"' && PRICE='"+price+"' ";<br />
So, we will change something like that.
string sstr="select * FROM ads where AD_TITLE='" + search + "' AND AD_TYPE = '" + type1 + "' AND PRICE='"+ price + "'";<br />
- Check this variable "sstr" in Quick Watch or Immediate Window.
- Copy the string from Quick Watch or Immediate Window.
- Paste in Query Analyzer and Run it.
(You should not get any error. this is about checking whether the SQL statement is correct or not.)
4. Changing static data to dynamic data in page1.
It is still working fine. we will remove the static code in page and replace with dynamic code.
So, the following code will be used again..
<a href="http://localhost/approvedplotfinal/classified/page2.aspx?li=<%#DataBinder.Eval(Container.DataItem,"AD_TITLE") %>,type=<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>,price=<%# DataBinder.Eval(Container.DataItem,"PRICE") %>"><br />
<%# DataBinder.Eval(Container.DataItem,"AD_TITLE") %><br />
</a><br />
- Run the application
- Click the link in page1.
- Check the Request.QueryString and SQL Statement in page2.
if it's working until now, you are done..
Please follow the step as I mention here.. let me know the result..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hai,
sorry for delay...
It is very helpful....i done as per your information...it is working fine Now my problem solved...Thanks alot.....But Now arise a new problem..How to set paging in this.???...Please give any idea or sample code.....
instead of "," i use '&'in this code......it is very helpful
-----------------------------------------------------------------------------
<a href="http://localhost/approvedplotfinal/classified/page2.aspx?li=<%#DataBinder.Eval(Container.DataItem,"AD_TITLE") %>,type=<%# DataBinder.Eval(Container.DataItem,"AD_TYPE") %>,price=<%# DataBinder.Eval(Container.DataItem,"PRICE") %>">
<%# DataBinder.Eval(Container.DataItem,"AD_TITLE") %>
</a>
-----------------------------------------------------------------------------
thanks once again
Biju
|
|
|
|
|
|
Hai
How to edit and update a particular DataList item??
Thanks and regards
Biju
|
|
|
|
|
bijeshputhalath wrote: How to edit and update a particular DataList item??
If you wanna do inserting, editing and deleting the record, I would suggest you to use "DataGrid" or "GridView" control instead of "DataList".
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hi,
I am developed a application as multiple image uploading.
I browse the image and add path of this in listbox.then click on upload button to upload the images. So I want to create thmbnail images on web page while adding the images paths to the listbox.
thanks
|
|
|
|
|
tulsulkar wrote: create thmbnail images on web page while adding the images paths to the listbox.
Use GetThumbnail() method in Image class
|
|
|
|
|
|
Sure.
How To: Creating Thumbnail Images
<br />
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(file));<br />
<br />
System.Drawing.Image thumbnailImage = image.GetThumbnailImage(64, 64, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);<br />
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hi Friends,
i m using FileUpload Control in my page
now i want, user not able to upload .exe file
for that i need to specify filter fo extensions
how do i Filter extensions???
thanks
Amit Metkar
3i-infotech, Mumbai.
|
|
|
|
|
No. AFAIK, it's not possible to do that with File Upload control. maybe. you may look around flash or ActiveX control.. I'm sure that HTML file control doesn't have that feature. So, you will have to check the extension at code-behind.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Amit.Amit.Amit..... wrote: now i want, user not able to upload .exe file
for that i need to specify filter fo extensions
Specifying filter is not possible in file upload control. But you can check the file extension like this and alert user regarding that
if (File1.PostedFile.FileName.EndsWith(".exe"))
{
}
else
|
|
|
|
|
Use javascript for the validations since u cant filter the HtmlInputFile control.
Ask if u want the code u have 2 do it in the onchange method.
|
|
|
|
|
Use javascript for the validations since u cant filter the HtmlInputFile control.
Ask if u want the code. u have 2 do it in the onchange method.
|
|
|
|
|
you should use this code:
private bool IsAccept(string fileName)
{
bool ok = false;
string ext = System.IO.Path.GetExtension(fileName);
if (ext == ".jpe" || ext == ".jpeg" || ext == ".pjpeg" || ext == ".gif"
|| ext == ".jpg" || ext == ".bmp" || ext == ".png" || ext == ".x-png")
{
ok = true;
}
return ok;
}
Hope that help you!
vtkiet05
|
|
|
|
|