|
Dear All,
I have a gridview with a dropdownlist inside a templatefield :
<asp:GridView ID="gvColumns" runat="server" AutoGenerateColumns="False" <br />
DataKeyNames="excelkolom"><br />
<Columns><br />
<asp:BoundField DataField="excelkolom" HeaderText="Excel kolommen" /><br />
<asp:TemplateField HeaderText="Database kolommen"><br />
<ItemTemplate><br />
<asp:DropDownList ID="ddlDbColumns" runat="server" AutoPostBack="true" <br />
DataSourceID="SqlDataSourceKhimportAll" DataTextField="Databasekolommen" <br />
DataValueField="Databasekolommen" <br />
OnSelectedIndexChanged="ddColumns_SelectedIndexChanged"><br />
</asp:DropDownList><br />
</ItemTemplate><br />
</asp:TemplateField><br />
</Columns><br />
</asp:GridView>
I want to get the text of the dropdownlist of the selected row:
string selection = gvColumns.Rows[gvColumns.SelectedRow.RowIndex].Cells[1].Text;
Im getting this error:
Object reference not set to an instance of an object.
How can i fix this?
Thanks in advance.
|
|
|
|
|
You have to use Gridview.FindControl() Method. Please do some research on it,you will able to resolve it by yourself.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
You should try
String TextOfDropDownList = ((DropDownList)gvColumns.Rows[gvColumns.SelectedRow.RowIndex].FindControl("ddlDbColumns")).SelectedItem.Text hope it helps!!
|
|
|
|
|
I have a question in asp.net, in the page code behind when filling a gridview with data for example, i send a reference of the gridview to a controller class to fill it with data to avoid writing a lot of code in the page's code behind for example i write in the page load the following:
Controller.GetData(DataGridView);
does this mean i'm sending too much data from the client to the server? Is there a difference in performance between this and between filling the data in the page's code behind? in my opinion there's no difference, as this code already runs on the server and controls are created on the server, so no effect on the amount of data transferred from client to server. any ideas?
lamia
|
|
|
|
|
lamia nabil wrote: does this mean i'm sending too much data from the client to the server
What are you talking about ? ??
Is it a web service where you are sending the DataGridView ?
If it is just a class, then the object is already loaded in memory. You can process the memory wherever you want.
|
|
|
|
|
Hi,
No, it's not a web service, it's a regular web application, i'm newly working in web applications and some collegues argued with me about this,claiming that this will increase the load on the server and lower the performance beside that it's not correct to send controls between presentation and bussines layers, but i thought if i send a reference of all controls (in an arraylist) in my page to the bussines layer and filling the data goes there, i would minimize code written in the page to bind all controls, but actually i didn't see any one doing this before, so i'm not sure if this was a good idea.
lamia
|
|
|
|
|
|
Well, Actually there is no difference. The only thing is that, we always try to separate the presentation layer with data.
It is just because of the separation of code. Say you have implemented 2 or more layers. Your intension is just to separate the Layers so that they could be reusable.
If you send the control, the data layer will be totally dependent on the presentation layer, and thus if this is what you do, then it will be better to have all the data layer classes in the App_Code of your project.
Actually, we all start creating Layers for separation of code, but gradually it becomes so much dependent that we cant plugin the other layer if the presentation layer is changed.
I think if you like to reduce the code, try creating a new Class in your APP_Code and place those code there. From Data layer, you call only for data and manipulation of controls could be made in your application layer.
By this, I definitely mean that there will be no difference if you send though. But at least this is not a good idea...
If you want to read on how to Refactor code, and reduce Dependency between layers, you might have a look into one of my article :
Simplify Code Using NDepend[^]
I think it will give you the idea on what I am talking about.
Cheers.
|
|
|
|
|
Thanks a lot for ur help.
Cheers.
lamia
|
|
|
|
|
how can we impliment online recharge for prepaid mobile in asp.net. Please reply as i need this urgently.
|
|
|
|
|
arunpal wrote: how can we impliment online recharge for prepaid mobile in asp.net
Is this is your work assignment ? What have you tried till now ? Please don't come up with any abstract question. This is not an easy task. You need some web services which will communicate with mobile to update the info. You need to contact with mobile connection provider.
arunpal wrote: Please reply as i need this urgently
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
If your client is the Service provider, just create the web interface and after payment is made, you update the value of the database.
If you a 3rd party, there should be some service available to the service provider which could update the value after recharge is made.
I dont know what is the problem you are having.
|
|
|
|
|
can anyone post any code as i m new for this.
|
|
|
|
|
Hi Dear,
Here I am trying to upload a photo.
protected void LoadImage() {
string UserName = Session["UserName"].ToString();
byte[] Data = Profile.GetImageData(UserName); //Stmt Correct where profile is class
if (Data != null)
{
MemoryStream stream = new MemoryStream(Data);
Bitmap bitmap = null;
bitmap = new Bitmap(stream);
bitmap.Save(Server.MapPath(@"~\UserPhoto.bmp"), system.Drawing.Imaging.ImageFormat.Bmp);
//Error:A Generic Error occurred in GDI+
bitmap.Dispose();
imgPhoto.ImageUrl = @"~\UserPhoto.bmp"; } }
I have created virtual directory and trying to open it directly from browser
|
|
|
|
|
This usually happens when you don`t have write permissions on your application folder. Try giving the permissions.
When you fail to plan, you are planning to fail.
modified on Tuesday, December 29, 2009 7:19 AM
|
|
|
|
|
Permissions?? in which Way..
I have tried giving all READ and WRITE permissions in Virtual Directory but it doesn't solve any problem
|
|
|
|
|
First of all it is better to write
Server.MapPath("~/userPhoto.bmp")
always use / to refer virtual path correctly (Even though with Server.MapPath it doesnt matter.
Seriously, there must be some problem writing in the folder where you are writing. As you are writing in the virtual directly directly check whether
ASPNET_WP or IIS_WPG has write permission to the virtual directory.
|
|
|
|
|
Hi abishek,
Thanq for your Answer.. I have checked all the Permissions
IIS-DefaultWebSite-MyProj-Rightclick-Properties.
Tab Virtual Directory and I have checked READ and WRITE Permissions..???
Still it doesnt solve..
|
|
|
|
|
Hi Frds,
I am getting problem in SSRS Chart control.
My output of SP is
------------------
Inc NAME NO% Yes%
----------------------------------------------
A1 Bujji 90% 100%
A2 Bujji1 30% 50%
B Type Acceptd Rejectd
B1 abc 20% 1%
B2 xyz 10% 2%
Above output is generating from SP Only. Here B Type Acceptd and Rejectd added like coloumns but those are part of Report
now I need to create a chart x- axis should have A1,A2,A3....An values and Y-axis should have bars with Yes% and No %
Here I am getting the Accepted and Rejectd values also. So please tell me how to prepare a chart putting condition for Inc in A1,A2
|
|
|
|
|
Dear Members,
I want to build an application like a mailer, in which i want to add a AJAX feature like a outlook, gmail (send to)etc i.e. if i enter any word into send to textbox related to that word email must be displayed on below from database (AJAX Autocomplete feature), if i select the email id and enter ";" and after that again enter any word again, the email id related to that word fetch from database.
I want to add This feature using ASP.NET .
if any help is possible please mail me on navrajyadav@gmail.com
Thank You,
Regards,
Navraj Yadav
|
|
|
|
|
Hi i want to show a pdf file in my asp.net form
Anyone please help me with this
|
|
|
|
|
You should have searched in this forum before asking. I have already answered this question several times.
Use this :
Byte[] docbytes = this.getDocumentbytes("PDFDocument.pdf");
Response.ContentType = "application/pdf";
Response.AddHeader("content-length",docbytes.Length.ToString());
Response.BinaryWrite(docbytes);
from getDocumentbytes read the file and return the bytes.
|
|
|
|
|
copy the pdf file and paste it in Server.Mappath.
Just place a Link and give the link to the pdf document..!
If reader is installed in your server you can view the document..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
but sashidhar,
this would only work if the link is open to all and also without any security imposed.
Also, it is not always a good idea to navigate the whole browser to the page, as we will loose control of the browser totally. Rather, I think if this is the requirement, it is always better to open a new window and then show the pdf.
|
|
|
|
|
If he is Using Forms Authentication..! Then it is secured..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|