|
Say you need to add a dropdownlist to the gridview,
DropDownList dr1= new DropDownList();
dr1.Items.Add("new");
dr1.Items.Add("newOne");
GridView1.Rows[1].Cells[1].Controls.Add(dr1);
If you want to add a control in every row, use GridView1_RowDataBound event in gridview
add like this,
e.Row.Cells[1].Controls.Add(new TextBox());
further if you google you will get.
|
|
|
|
|
Thanks you for your reply Baran M
But i don't want to use dropdownlist from where user select the correct the objectives.What I am trying "is display all question with their objective in radiobuttonlist and when the user over selecting the objectives it click on submit button and result will be displayed".
What you have saying about is one of the sample project which is in the official site of asp.net, a tutorial video.In which they uses the gridview to show the
Question No
Question Text
It's $ objectives
and a dropdownlist from where user have to choose the correct objectives like(A,B,C,D)
If you can give any other advice it well be very greatfull
AGAIN, THANKS FOR THE REPLAY
|
|
|
|
|
If you add controls to gridview while page_load, it will be created even while postback action. So if you check now you will get status of the checkbox which you have added to gridview. I have tried it but I doubt whether this is a best approach.
|
|
|
|
|
thank you for your reply sir..
You are talking about using gridview but
instead of using grid view i am using datalist to display the question like this
Q1. Here is the first question
a) Option a
b) Option b
c) Option c
d) Option d
Q2. Second question
a) Option a
b) Option b
c) Option c
d) Option d
Next..
SubMit Button which led the result page
Here is the code through which i bind the question with the label and radiobuttonlist
<br />
<asp:DataList ID="DataList1" runat="server" DataSourceID="AccessDataSource1"><br />
<AlternatingItemStyle BackColor="#CCCCCC" /><br />
<ItemStyle BackColor ="#EEEEEE" /><br />
<ItemTemplate><br />
<p><%#Eval("QuestionNo") %>. <asp:Label ID="TextLabel" runat="server" Text='<%#Eval("QuestionText") %>'></asp:Label></p><br />
<asp:AccessDataSource ID="AccessDataSource2" runat="server"<br />
DataFile="~/App_Data/dbstudent.mdb"<br />
SelectCommand='<%# Eval("QuestionNo", "SELECT OptionA,OptionB,OptionC,OptionD FROM [BankQuestionBiology] WHERE QuestionNo = {0}") %>'><br />
</asp:AccessDataSource><br />
<asp:RadioButtonList ID="RadioButtonList1" runat="server"<br />
DataSourceID="AccessDataSource2"><br />
</asp:RadioButtonList><br />
</ItemTemplate><br />
</asp:DataList><br />
But it is giving a Syntax error
Syntax error (missing operator) in query expression 'QuestionNo = QB 10001'.
Could you help with this code or hint about a better approach
Again thanks for the reply
|
|
|
|
|
Can you share the code and database sneha or
send me on mkclrakesh@gmail.com
Rakesh Gaur
Mumbai
|
|
|
|
|
hi sneha
Can you send me the code and database of this project .
on mkclrakesh@gmail.com
Rakesh Gaur
|
|
|
|
|
I have a regular expression where i enter an image path with certain extention:
if i enter C:\Image.jpg it works fine but i enter \\sam\Image.jpg it doesnt work.
here is the validation expression:
ValidationExpression="[a-zA-Z0_9].*\b(.gif|.GIF|.jpeg|.JPEG|.jpg|.JPG|.bmp|.BMP)\b"
how can i add to validation expression to accpt \\ at the beginning.
thanks
|
|
|
|
|
|
I am currently hosting in a shared environment with no access to the servers IIS, configs or anything. All I have is FTP.
Ive searched and have found lots of URL rewriting techniques that will only work if you have access to the server.
So how do I do it?
Thanks
|
|
|
|
|
That not true. You can do the url rewritting in a number of ways even without changing IIS settings.
Here [^]is good article on how to do it.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi. Thanks that looks useful, but it doesnt appear to show how to do it without extentions?
|
|
|
|
|
roguemat wrote: but it doesnt appear to show how to do it without extentions?
It does. Did you see the example using UrlRewriter.net?
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Yes, thanks .
|
|
|
|
|
|
Firstly we don't work for you and Stop Using the words like "urgent" because you don't pay us to help you.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
In GridView1_RowUpdating event set a GridView1.SelectedIndex property with e.RowIndex.
So you can get the row id from that
|
|
|
|
|
how to update data in textbox control after retrieving from database and also i want to know that how to use query string to get data from database in update mode.Please help me with one example with C#.net coding and asp.net coding.
rajiv
|
|
|
|
|
Google is the best answer.
|
|
|
|
|
//insert to database
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();
string empcode = txtempcode.Text;
string empname = txtEmpname.Text;
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText = "insert into ankemp values(@empcode,@empname)";
com.Parameters.Add("@empcode", empcode);
com.Parameters.Add("@empname", empname);
com.ExecuteNonQuery();
bindgrid();
//datasource to grid
void bindgrid()
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();
string query = "select * from ankemp";
SqlDataAdapter da = new SqlDataAdapter(query.ToString(), con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
//while clicking the fetch button in grid (in aspx page <commandname="fetch" commandargument="<%# Bind("empcode") >">
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "fetch")
{
int empcode = int.Parse(e.CommandArgument.ToString());
fetch(empcode);
}
}
//fetch method
public void fetch(int empcode)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();
txtempcode.Text = empcode.ToString();
StringBuilder sb = new StringBuilder();
sb.Append(" select empname, ");
sb.Append(" from ankemp where empcode="+empcode);
SqlCommand com = new SqlCommand(sb.ToString(), con);
SqlDataReader dr = com.ExecuteReader();
if (dr.Read())
{
txtEmpname.Text = dr["empname"].ToString();
}
//update
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();
string empcode = txtempcode.Text;
string empname = txtEmpname.Text;
string update = "update ankemp set empname='" + empname + "'where empcode='" + empcode + "'";
SqlCommand cmd = new SqlCommand(update, con);
cmd.ExecuteNonQuery();
bindgrid();
con.Close();
//deleteing (in aspx page <commandname="delete">
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["connect"].ToString());
con.Open();
int i = e.RowIndex;
string empcode = GridView1.Rows[i].Cells[0].Text;
string del = "delete from ankemp where empcode='" + empcode + "'";
SqlCommand com = new SqlCommand(del, con);
com.ExecuteNonQuery();
bindgrid();
}
Padmanabhan
|
|
|
|
|
I have a problem with my ajax model pop up..When i use model pop up in master page it create issues..When i use the same master page and a tab container inside the master page at the time when the model popup get fired the data inside the tabcontainer did not get display pls give me a solution
Oopppzz!!!!!!!
|
|
|
|
|
Hi Libin,
The problem which I partly understood forced me to tell you that when the modal popup gets fired, I guess no postback event gets fired right? I guess you are showing the modal popup on client side events. if you have written the code to populate the gridview on server side then it will never be populated. There may be two work around for this. One is to show modal popup from cdoe-behind like ModalPopupExtender1.Show() and callthe gridviews' populate method, Second one would be to show the modal popup in client side and call the gridview's populate method asynchronusly.
Regards
Saanj
Either you love IT or leave IT...
|
|
|
|
|
hi guys,
i'm working on a project that requires d app 2 send SMSs. however, i have to call another page <www.biosmart-ng.com sendsms.aspx="">
pls how do i do this w/out redirecting from d original site?
He who goes for revenge must first dig two graves.
|
|
|
|
|
You going to redirect your user to other page in HTTPS environment right. Why dont you think webservices instead 2 send SMSs ?
|
|
|
|
|
I'm not actually doing the sending of SMSs. I'm utilising a service. And it requires me to send username, password, and other details to that page for the sms to be sent.
Ex: sendSMS.aspx?user=john;pass=0000;msg=Hello SMS
He who goes for revenge must first dig two graves.
|
|
|
|
|
You can send sms in your Application than going to sites. What you need is a Sms gateway. there are Some provider of this service see this
http://www.dotnetfunda.com/forums/thread552-how-to-send-sms-from-aspnet.aspx[^]
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|